Reputation: 72
I am trying to change the text color of the text in Default Action Bar using Theme. I can easily change the background of the Status Bar, but whatever I do, the text stays the same in Action Bar:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.MyAapp" parent="Theme.AppCompat.DayNight">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/ocean</item>
<item name="colorPrimaryVariant">@color/light_ocean</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/ocean</item>
<item name="colorSecondaryVariant">@color/dark_ocean</item>
<item name="colorOnSecondary">@color/ocean</item>
<!-- Status bar color. -->
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
Is it possible to override it in Theme.AppCompat.DayNight? I need to use this theme. I will appreciate your help.
Upvotes: 1
Views: 1775
Reputation: 2869
You need to define toolbar_style with parent: Widget.AppCompat.ActionBar like this example:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorAccent">@color/highlightRed</item>
<item name="actionBarTheme">@style/toolbar_style</item>
</style>
<style name="toolbar_style" parent="Widget.AppCompat.ActionBar">
<item name="android:textColorPrimary">@color/white</item>
</style>
Upvotes: 1
Reputation: 61
Hello this is a map for you. If you do not have some of them, you must define it
Upvotes: 3
Reputation: 51
<!-- Base application theme. --> <style name="Theme.MyAapp" parent="Theme.AppCompat.DayNight"> <!-- Primary brand color. --> <item name="colorPrimary">@color/ocean</item> <item name="colorPrimaryVariant">@color/light_ocean</item> <item name="colorOnPrimary">@color/white</item> <!-- Secondary brand color. --> <item name="colorSecondary">@color/ocean</item> <item name="colorSecondaryVariant">@color/dark_ocean</item> <item name="colorOnSecondary">@color/ocean</item> <!-- Status bar color. --> <!-- Status bar color. --> <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item> <!-- Customize your theme here. --> <item name="android:actionBarStyle">@style/ThemeOverlay.MaterialComponents.ActionBar</item> </style> <style name="hemeOverlay.MaterialComponents.ActionBar" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar"> <item name="android:textColor">@color/black</item> </style>
Upvotes: 1