Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change toolbar menu item text color for pre Lollipop and Lollipop versions

I am using Toolbar for the purpose of material design in my application. Everything working fine but except when it comes to change the menu item text color I am completely stuck up with the solution. I am also posting screenshot of the text that should be taken and code I am using in my application for your reference. I tried several alternate methods like assigning as follows

<item name="android:actionMenuTextColor">@color/white</item>

<item name="android:textColor">#000</item>

But known of the above solutions works for me.

Requirement screenshot:

enter image description here

Need to change SKIP menu item from black to white color.

styles.xml

<style name="ToolBarTheme" parent="@style/Theme.AppCompat.Light">
        <item name="colorPrimary">@color/blue</item>
        <item name="colorPrimaryDark">@color/blue</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
        <item name="android:actionMenuTextColor">@color/white</item>
        <item name="android:textColor">#000</item>

    </style>

toolbar.xml

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|enterAlways"
    android:fitsSystemWindows="true"
    android:background="?attr/colorPrimary"/>

manifests

<activity
            android:name=".activity.HomeActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:configChanges="keyboard|screenLayout|orientation"
            android:theme="@style/ToolBarTheme"></activity>

I really dont know where I am committing mistake. Please help me. Thanks in advance

like image 366
Chandru Avatar asked Nov 29 '25 00:11

Chandru


1 Answers

Change this

<item name="android:actionMenuTextColor">@color/white</item>

to

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

And apply the theme to the toolbar:

android:theme="@style/ToolBarTheme"

You style your widgets and provide themes for your activity.

like image 107
Raghunandan Avatar answered Nov 30 '25 13:11

Raghunandan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!