How to change ActionBar's action text color using AppCompat

瘦欲@ 提交于 2019-11-30 06:40:21
Raghunandan

Use

<item name="android:actionMenuTextColor">@color/font_half_white</item>
// added style directly 

Instead of

<item name="android:actionMenuTextColor">@style/MyActionButtonStyle</item>

in res/values-14/styles.xml

In res/values/styles.xml

<item name="actionMenuTextColor">@color/font_half_white</item>

I used a Red Color for testing. See the Action menu Item Home that is red in the snap

Edit:

Full Code

In res/values-14/styles.xml

<resources>

    <!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- API 14 theme customizations can go here. -->
            <item name="android:actionMenuTextColor">@color/red</item>
    </style>

</resources>

Then in res/values/stles.xml

  <resources>
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <!-- API 11 theme customizations can go here. -->
         <item name="actionMenuTextColor">@color/red</item>
    </style>

</resources>

In manifest

android:theme="@style/AppBaseTheme" >

Another snap

You can use this to change the text of the Action Bar irrespective of your appcompat version.Give the desired color's hex code and add this in the onCreate().

actionBar.setTitle(Html.fromHtml("<font color='#ff0000'>Some Title</font>"));
  1. Check that in your layout xml file you don't have an android:theme attribute specified for your <Toolbar>, which would have priority over the main theme

  2. Override your actionBarStyle attribute as pointed out everywhere over the internets.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!