今天在看一些源码的时候,发现人家设置标题都不用样式布局文件,看了后感觉还是蛮方便的,
具体操作如下:
[java]
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.share);
添加代码
requestWindowFeature(Window.FEATURE_NO_TITLE);
设置不要标题,
然后在配置文件添加配置如下:
[java]
< xml version="1.0" encoding="utf-8" >
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
android:layout_height="44dp"
android:background="#486a9a"
android:gravity="center"
android:text="分享例子"
android:textColor="@android:color/white"
android:textSize="18sp" />
android:id="@+id/share"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="分享" />

此操作容易控制,但是布局多的话会写很多代码。