Change the color of an ActionBar text

I want to change my ActionBar color to blue (# 0c01e3). My code works because the background property of the action bar does its job. But the text will not change. Any ideas? I am using ABS.

<style name="MyActionBar1" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse"> <item name="android:backgroundSplit">#06e301</item> <item name="android:backgroundStacked">#06e301</item> <item name="android:background">#06e301</item> <item name="background">#06e301</item> <item name="backgroundSplit">#B9001F</item> <item name="android:textColor">#0c01e3</item> > 

enter image description here

Update

:

enter image description here

+4
source share
5 answers

The topic has an attribute actionItemTextColor that controls this color.

Do not forget to specify it with the android: prefix and without it when using ActionBarSherlock.

+1
source

Install this on a Java .It page works for me

 ActionBar ab = getActionBar(); ab.setTitle(Html.fromHtml("<font color='#ffffff'>App Name</font>")); 
+2
source

add this and then try

     <item name="android:textColor">#ffffff</item> 
+1
source

To improve @IntelliJ Amiya's answer:

  getActionBar().setTitle( Html.fromHtml("<font color='" + getResources().getColor(R.color.my_color) + "'>" + getString(R.string.title_home) + "</font>")); 
0
source

If you want to change this with xml ... This is what worked for me ...

 <style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> <item name="android:background">@color/titleBarBgColor</item> <item name="android:titleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item> <item name="android:subtitleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item> <!-- Support library compatibility --> <item name="background">@color/titleBarBgColor</item> <item name="titleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item> <item name="subtitleTextStyle">@style/EldTheme.ActionBar.TitleTextStyle</item> </style> <style name="EldTheme.ActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"> <item name="android:textColor">@color/titleBarTextColor</item> </style> 
0
source

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


All Articles