Change title color of theme element Theme.AppCompat.Light.DarkActionBar android

I want to change the color of the title of the action bar to white in android. and I use the theme in Theme.AppCompat.Light values ​​and 14 Theme.AppCompat.Light.DarkActionBar
I already tried in the 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 -14 folder values

  <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 the color of the ActionBar name does not change.

+6
source share
3 answers

You can specify the background color of the ActionBar 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 android: omitted.

+5
source

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"/> 
+1
source

You should also verify that your android:theme attribute is not specified in your layout XML file, which takes precedence over the main theme.

0
source

Source: https://habr.com/ru/post/981220/


All Articles