Android development
text color
menu item
UI customization
Android Studio

How to change the Text color of Menu item in Android?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Changing menu item text color in Android depends on which menu you actually mean. An options menu in the app bar, a popup menu, and a navigation drawer menu are styled differently, so there is no single universal API that works for all of them.

In practice, the most common solutions are theme-based styling for popup-style menus and SpannableString for per-item text color changes. The right choice depends on whether you want a global style or a one-off override.

One-Off Color Change With SpannableString

If you want to change the color of a specific menu item title, a practical approach is to wrap the title in a SpannableString.

Kotlin example:

kotlin
1import android.graphics.Color
2import android.os.Bundle
3import android.text.SpannableString
4import android.text.style.ForegroundColorSpan
5import android.view.Menu
6import androidx.appcompat.app.AppCompatActivity
7
8class MainActivity : AppCompatActivity() {
9
10    override fun onCreateOptionsMenu(menu: Menu): Boolean {
11        menuInflater.inflate(R.menu.main_menu, menu)
12
13        val item = menu.findItem(R.id.action_settings)
14        val title = SpannableString(item.title)
15        title.setSpan(
16            ForegroundColorSpan(Color.RED),
17            0,
18            title.length,
19            0
20        )
21        item.title = title
22
23        return true
24    }
25}

This is simple and reliable for a small number of items. It works well when you want one menu action, such as “Delete,” to stand out visually.

Styling Popup Menus Through Theme Attributes

For popup menus, theme styling is often cleaner than touching each item manually. A PopupMenu can use a themed context so its text appearance comes from styles.

Example popup menu:

kotlin
1val wrapper = ContextThemeWrapper(this, R.style.MyPopupMenuStyle)
2val popup = PopupMenu(wrapper, anchorView)
3popup.menuInflater.inflate(R.menu.main_menu, popup.menu)
4popup.show()

And the style:

xml
1<style name="MyPopupMenuStyle" parent="ThemeOverlay.AppCompat.Light">
2    <item name="textAppearanceLargePopupMenu">@style/MyPopupMenuText</item>
3    <item name="textAppearanceSmallPopupMenu">@style/MyPopupMenuText</item>
4</style>
5
6<style name="MyPopupMenuText" parent="TextAppearance.AppCompat.Widget.PopupMenu.Large">
7    <item name="android:textColor">@color/menu_text_color</item>
8</style>

This is a better approach when you want a consistent popup-menu look across the app.

Options Menu in Toolbar-Based Apps

In modern Android apps, menu items are usually shown in a Toolbar rather than the old framework action bar. That means the overall menu appearance is influenced by the toolbar theme and text appearances.

Basic toolbar setup:

xml
1<androidx.appcompat.widget.Toolbar
2    android:id="@+id/toolbar"
3    android:layout_width="match_parent"
4    android:layout_height="?attr/actionBarSize"
5    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
6    app:popupTheme="@style/MyPopupMenuStyle" />

The popupTheme controls the overflow menu appearance. That is often the actual place to style text color for the menu you see when the user taps the three-dot overflow button.

Typical menu resource:

xml
1<menu xmlns:android="http://schemas.android.com/apk/res/android"
2    xmlns:app="http://schemas.android.com/apk/res-auto">
3
4    <item
5        android:id="@+id/action_settings"
6        android:title="Settings"
7        app:showAsAction="never" />
8
9    <item
10        android:id="@+id/action_delete"
11        android:title="Delete"
12        app:showAsAction="never" />
13</menu>

If you want all menu items to share a theme-based color, prefer styling. If you want one specific item to look different, prefer SpannableString.

When Icons Need Matching Color

Changing only the text color can make the menu look inconsistent if the icons still use the old tint. If your menu items have icons, tint them to match:

kotlin
val item = menu.findItem(R.id.action_delete)
item.icon?.setTint(Color.RED)

That is especially useful in destructive actions where both icon and label should communicate the same meaning.

Which Approach Should You Use

Use SpannableString when:

  • only one or two items need custom color
  • the styling is conditional at runtime
  • you want a quick per-item solution

Use theme or text appearance styling when:

  • many menu items should share the same style
  • you are styling popup or overflow menus
  • consistency across screens matters more than one-off customization

That balance keeps the code maintainable.

Common Pitfalls

One common mistake is changing the toolbar title color and expecting menu item text to change too. Those are different UI elements.

Another mistake is styling the app theme but forgetting that the overflow popup may be controlled by popupTheme instead of the main activity theme.

It is also easy to rely on old framework ActionBar examples in a modern AppCompat or Material app. In current Android code, Toolbar styling is usually the real answer.

Finally, if you recolor the text but not the icons, the menu can end up looking visually inconsistent.

Summary

  • Menu item text color depends on the type of menu and how it is rendered.
  • Use SpannableString for one-off per-item color changes.
  • Use theme styling and popupTheme for consistent popup and overflow menu text appearance.
  • In modern apps, menu styling is often really Toolbar styling.
  • Keep icon tint and text color aligned when the menu item has both.

Course illustration
Course illustration

All Rights Reserved.