Reputation: 1589
I was digging into the android theme and styles. As part of that, I was trying to change the color of the action bar. But with my code, the background of the action bar has been changed but the title on it is not displaying. Please find my theme.xml below
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<item name="actionBarStyle">@style/MyActionBar</item> // My change
</style>
<style name="MyActionBar">
<item name="background">@android:color/holo_green_dark</item>
<item name="android:textColor">@android:color/white</item>
<item name="titleTextColor">@android:color/white</item>
</style>
</resources>
Right now I am getting the following output
What is wrong with my code? Can anyone help me to sort out this issue?
Thanks
Upvotes: 0
Views: 321
Reputation: 397
You need to use a Theme.AppCompat theme (or descendant) with this activity.
Add a parent something like this parent="Theme.AppCompat.Light.DarkActionBar"
If it doesn't help then please share your full code.
Upvotes: 2