Android开发如何在4.0及以上系统中自定义TitleBar
4.0系统以上自定义标题栏报错解决办法:
1、为布局文件修改style.xml
此处的style.xml在values-11或者value-14中,否侧会报错:you cannot combine custom titles with other title features
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="CustomizedWindowTitleBackground">
<item name="android:background">#047BF0</item>
</style>
<style name="titlebarstyle" parent="android:Theme">
<item name="android:windowTitleSize">55dp</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomizedWindowTitleBackground</item>
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
2、在AndroidManifest.xml添加主题样式
android:theme="@style/titlebarstyle"
<activity android:name="com.gnnuit.mobilesafe.ui.TaskManagerActivity" android:label="@string/task_manager" android:theme="@style/titlebarstyle" > </activity>

浙公网安备 33010602011771号