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);