I am trying to customize the action bar in my android application. The following is in my 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
.
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:
<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:
<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>