如何定制Activity的标题栏

时间:2015-01-29 23:44:36   收藏:0   阅读:174

 requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

        setContentView(R.layout.main);

        //自定义标题栏
        mWindow = getWindow();
        mWindow.setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.titlebar);

 

titlebar.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
>
        <TextView
                android:text="@string/app_name"
                android:textColor="#000"
                android:paddingRight="3.0dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        <TextView
                android:text="@string/battery_text"
                android:textColor="#000"
                android:paddingRight="3.0dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        <TextView
                android:id="@+id/battery_text"
                android:textColor="#00f"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
</LinearLayout>

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!