android 系统定义titlebar的背景色
<itemname="windowTitleBackgroundStyle">@android:style/WindowTitleBackground</item>
<stylename="WindowTitleBackground">
<itemname="android:background">@android:drawable/title_bar</item>
</style>
android 系统定义contentoverlay的背景图片
<itemname="windowContentOverlay">@android:drawable/title_bar_shadow</item>
修改title的背景色
写个themes文件
<resources>
<stylename="XTheme"parent="android:Theme">
<!--Windowattributes-->
<itemname="android:windowTitleStyle">@style/XWindowTitle</item>
<itemname="android:windowTitleBackgroundStyle">@style/StatusBarBackground</item>
<itemname="android:windowContentOverlay">@null</item>
</style>
</resources>
写styles文件
<resources>
<stylename="StatusBarBackground">
<itemname="android:background">@drawable/shape</item>
</style>
<stylename="XWindowTitle"parent="android:WindowTitle">
<itemname="android:shadowColor">#BB000000</item>
<itemname="android:shadowRadius">0</item>
</style>
</resources>
这个XWindowTitle要继承WindowTitle。
在manifext中给自定义的activity申明主题。
<activityandroid:name=".Entry"
android:label="@string/app_name"
android:theme="@style/XTheme">
<intent-filter>
<actionandroid:name="android.intent.action.MAIN"/>
<categoryandroid:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
也可以手动设置
setTheme(themeid);