Android自定义标题栏

来源:互联网 发布:辐射4 室内光源优化 编辑:程序博客网 时间:2024/06/03 22:38

【2014年3月2日 星期日】

经常用到的东西,网上有很多文章了,自己做个标记。

 

--------------------------------


有兩個部分;
1、代碼設置;
2、style.xml的設置;

3、AndroidManifest.xml的设置

--------------------------------


1、代碼設置(xxActivity.java)
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_group);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);


2、style設置(res/values/style.xml)
<style name="CustomWindowTitleBackground">
<item name="android:background">#f8f5e4</item>
</style>

<style name="title" parent="android:Theme">
<item name="android:windowTitleSize">40dp</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>

3、AndroidManifest.xml配置
<application
 android:theme="@style/title" >

</>

0 0
原创粉丝点击