尝试以100种方式更改操作栏的颜色,但它仍然相同。这是我的代码:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:statusBarColor">#00B0FF</item>
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#ffffff</item>
</style>
有人可以解释一下我的错误在哪里吗?
答案 0 :(得分:1)
试试这个:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="android:statusBarColor">#00B0FF</item>
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#ffffff</item>
</style>
答案 1 :(得分:0)
如果您是扩展材料设计api 21 =&gt; take a look
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>
但如果你是扩展AppCompat =&gt; take a look
<resources>
<!-- inherit from App Compat theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light"">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="colorAccent">@color/accent</item>
</style>
</resources>
我们现在在所有平台上使用Toolbar / ActionBar的支持实现,这意味着我们不再读取与操作栏相关的任何android:属性。克里斯巴恩斯
答案 2 :(得分:0)
请在value-v14中尝试此代码,并在Munifest.xml中选择主题为myAppTheme
<style name="ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/color1</item>
<item name="android:backgroundStacked">@color/color1</item>
<item name="android:backgroundSplit">@color/color1</item>
<item name="android:statusBarColor">@color/staus_bar_color</item>
</style>
<style name="myAppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/ActionBar</item>
</style>