--ADVERTISEMENT--

Android action bar option menu is also known as overflow menu which is shown to the users when they click/press the menu key on android phone and tablet. Options menu can be customized according to our need, we can set or change the background color and text color. You can’t change the text and background color using android themes. In this tutorial, you will learn how to change the background color of android action bar option menu programmatically.

Changing the background color of your android app option menu is not the very difficult. Someone write it as difficult and tricky but here I am going to show you to change background and text color of your app option menu with simplest ways. Following is the step by step guide to change the background color of android option menu/ overflow menu.

Related:
Floating Action Button (FAB) Using Android Design Support Library
Android ActionBar Tabs Example
Android Toolbar Example: How to Use Toolbar as ActionBar

Android Example: Change the Background & Text Color of Android Option Menu


Following is the content different files of android project to change the background and text color of android overflow menu.

Java Activity File


Following is the complete code of java activity file. Here you will see two override methods to add menu items in android application, onCreateOptionsMenu and onOptionsItemSelected.

src/ OverflowMenuBackgroundColor.java


Option Menu Items


Here I have added three items for option menu.

res/menu/menu_items.xml

Styles.xml File


To add background and text color of overflow menu just add two line of more code android:textColor and itemBackground in your project styles.xml file. Following is the complete content of styles.xml file.

res/values/styles.xml

Colors.xml File


In this file I have defined different color value for option menu background, app text color, accent color, toolbar/app bar color, etc.

res/values/colors.xml

XML Layout File


Default content of android XML layout file.

res/layout/ android_overflow_menu_text_background_color.xml


Strings.xml File


res/values/strings.xml

Android Example: Change the Background & Text Color of Android Option Menu

Now, run your How to Change the Background and Text Color of Android ActionBar Option Menu application and click the more button from actionbar/toolbar of your app, you will see the different background color and text color of option menu.

Post a Comment

Powered by Blogger.