我正试图改变我的动作条的颜色。
我已将以下代码放入styles.xml文件中:

<style name="MyCustomTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/MyActionBarTheme</item>
</style>

<style name="MyActionBarTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:background">#a4dba3</item>
</style>

然后,我进入android清单文件并输入以下内容,因为我希望所有活动的操作栏都相同:
    <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/MyCustomTheme" >

我运行了模拟器,注意到操作栏已经消失了。
请问我做错什么了?

最佳答案

MyActionBarTheme设置的父样式应该是
@android:style/Widget.Holo.Light.ActionBar
或类似的:

<style name="MyActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">#a4dba3</item>
</style>

因为你刚刚将它设置为全息光主题,所以实际上没有用于实际操作栏的样式。
有关更多信息,请单击here,尤其是在API 11下进行目标定位时。

关于android - 更改操作栏颜色时,操作栏消失了,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22875703/

10-12 06:17