android 设置主题

android 系统定义titlebar的背景色

<item name="windowTitleBackgroundStyle">@android:style/WindowTitleBackground</item> 

<style name="WindowTitleBackground">  

        <item name="android:background">@android:drawable/title_bar</item>  

</style>

 

android 系统定义contentoverlay的背景图片

<item name="windowContentOverlay">@android:drawable/title_bar_shadow</item>

 

 

修改title的背景色

写个themes文件

<resources>  

    <style name="XTheme" parent="android:Theme">       

             <!-- Window attributes -->  

        <item name="android:windowTitleStyle">@style/XWindowTitle</item>      

        <item name="android:windowTitleBackgroundStyle">@style/StatusBarBackground</item>        

        <item name="android:windowContentOverlay">@null</item>  

    </style>     

</resources>  

写styles文件

<resources>       

    <style name="StatusBarBackground">  

        <item name="android:background">@drawable/shape</item>  

    </style>          

    <style name="XWindowTitle" parent="android:WindowTitle">  

        <item name="android:shadowColor">#BB000000</item>  

        <item name="android:shadowRadius">0</item>  

    </style>  

</resources>

这个XWindowTitle要继承WindowTitle。

在manifext中给自定义的activity申明主题。

<activity android:name=".Entry"  

           android:label="@string/app_name"  

           android:theme="@style/XTheme">  

     <intent-filter>  

         <action android:name="android.intent.action.MAIN" />  

         <category android:name="android.intent.category.LAUNCHER" />  

     </intent-filter>  

 </activity>  

也可以手动设置

setTheme(themeid);

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值