[英]Android actionbar customization does not change color
I am trying to customize the action bar in my android application.我正在尝试在我的 android 应用程序中自定义操作栏。 The following is in my
styles.xml
:以下是我的
styles.xml
:
<style name="MyTheme" parent="Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="Widget.AppCompat.Light.ActionBar">
<item name="backgroundColor">#000000</item>
</style>
And I have我有
<activity android:name=".MainActivity"
android:theme="@style/MyTheme">
in my AndroidManifest.xml
.在我的
AndroidManifest.xml
。
My expectation is that this should turn the action bar black.我的期望是这应该使操作栏变黑。 However, this does not happen, the action bar stays white.
但是,这不会发生,操作栏保持白色。 I would be very happy for any pointers to why my expectation does not match reality.
对于我的期望为何与现实不符的任何指示,我将非常高兴。 I am happy to provide more details if needed.
如果需要,我很乐意提供更多详细信息。
If you are using an ActionBar
you can use the actionBarStyle
attribute in your app theme:如果您使用的是
ActionBar
,则可以在应用主题中使用actionBarStyle
属性:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">#000000</item>
</style>
You can also use the actionBarTheme
attribute:您还可以使用
actionBarTheme
属性:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarTheme">@style/ThemeOverlay.ActionBar</item>
</style>
<style name="ThemeOverlay.ActionBar" parent="">
<item name="colorPrimary">#000000</item>
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.