简体   繁体   中英

Change text of android menu item

My menu layout looks like this:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_change_pin"
    android:title="@string/action_change_pin"
    android:textColor="#000000"
    android:orderInCategory="100"
    app:showAsAction="never" />
<item android:id="@+id/action_logout"
    android:title="@string/action_logout"
    android:orderInCategory="100"
    app:showAsAction="never" />

I want to change these two items' text color to white from black. How can i do that?

I think u need to change the style: try this :

put this in your theme

 <item name="android:itemTextAppearance">@style/myCustomMenuTextApearance</item>

and in your styles.xml:

<style name="myCustomMenuTextApearance" parent="@android:style/TextAppearance.Widget.IconMenu.Item">
    <item name="android:textColor">@color/your_color</item>
</style>

should help u out

In your theme.xml

<style name="LightTheme" parent="@style/Theme.AppCompat.Light">
    <item name="actionMenuTextColor">#FFF</item>
    <item name="android:actionMenuTextColor">#FFF</item>
</style>

Try this:

    <style name="ThemeName" parent="@style/Theme.Sherlock.Light">
         <item name="actionMenuTextColor">@color/white</item>
         <item name="android:actionMenuTextColor">@color/white</item>
    </style>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM