change action bar title color Theme.AppCompat.Light.DarkActionBar android
12,481
Solution 1
You can specify the background color of the ActionBar
by using the colorPrimary
attribute; something like the following:
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@android:color/white</item>
</style>
The above is a special tag created for AppCompat
; you will notice that the android:
namespace is omitted.
Solution 2
If you are using Theme.AppCompat.Light.NoActionBar do
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@color/background_material_dark"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
Author by
John
Updated on June 14, 2022Comments
-
John almost 2 years
I wants to change the action bar title color to white in android . and i am using theme in values
Theme.AppCompat.Light
and values-14Theme.AppCompat.Light.DarkActionBar
I have tried so far in values folder :<style name="AppBaseTheme" parent="Theme.AppCompat.Light"> <item name="actionBarStyle">@style/MyActionBar</item> </style> <style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> <item name="android:textColor">@android:color/white</item> </style>
and values -14 folder
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="actionBarStyle">@style/MyActionBar</item> </style> <!-- ActionBar styles --> <style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> <item name="android:textColor">@android:color/white</item> </style>
but ActionBar title color is not changing.
-
Jason Hu about 9 yearsThe question was changing the text color not the background color. Yes you can set
colorPrimary
on AppCompat similar to Material action bar, but you can't settextColorPrimary
in the same regard, which is why he is asking the question. -
sahil shekhawat almost 9 yearsQuestion asks the method to change actionbar text color, not the color of action bar itself.