Ask Your Question
1

How can the color of text in Android actionbar submenu be modified?

asked 2022-12-06 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-09-25 16:00:00 +0000

scrum gravatar image

To modify the color of text in Android action bar submenu, you can first create a style in your styles.xml file with a parent of Theme.AppCompat.

<style name="ActionBarSubMenuText" parent="Theme.AppCompat">
    <item name="android:textColorSecondary">@color/submenu_text_color</item>
</style>

Then, apply this style to the submenu items in your menu.xml file.

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/menu_item"
        android:title="Menu Item"
        android:icon="@drawable/ic_menu_item"
        app:showAsAction="always">
        <menu>
            <item
                android:id="@+id/submenu_item"
                android:title="Submenu Item"
                app:actionLayout="@layout/action_layout"
                app:showAsAction="always"
                app:actionViewClass="android.widget.LinearLayout"
                android:theme="@style/ActionBarSubMenuText"/>
        </menu>
    </item>
</menu>

Note that 'submenutextcolor' is a color resource that you can define in your colors.xml file.

<color name="submenu_text_color">#FFFFFF</color>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-12-06 11:00:00 +0000

Seen: 15 times

Last updated: Sep 25 '21