How to Change the Background Color of the Options Menu

how to change option menu background color

There problem with the material theme

 <style name="Theme.MyApplication" parent="Theme.AppCompat.DayNight.DarkActionBar">
<item name="android:itemBackground">@color/bluish_green</item>
</style>

<style name="ThemeOverlay.MyTheme" parent="Theme.MyApplication">
<!-- To change the popup menu and app text color -->
<item name="android:textColor">@color/white</item>
<!-- To change the background of options menu-->
<item name="android:itemBackground">@color/black</item>
<item name="android:popupBackground">@color/black</item>
<item name="android:drawablePadding">0dp</item>
<item name="android:dividerHeight">1dp</item>

</style>

How to change the background color of Action Bar's Option Menu in Android 4.2?

There is an easy way to change the colors in Actionbar
Use ActionBar Generator and copy paste all file in your res folder and change your theme in Android.manifest file.

Toolbar options menu background color

To change the toolbar options menu color, add this to your toolbar element

app:popupTheme="@style/MyDarkToolbarStyle"

Then in your styles.xml define the popup menu style

<style name="MyDarkToolbarStyle" parent="ThemeOverlay.AppCompat.Light">
<item name="android:colorBackground">@color/mtrl_white_100</item>
<item name="android:textColor">@color/mtrl_light_blue_900</item>
</style>

Note that you need to use colorBackground not background. The latter would be applied to everything (the menu itself and each menu item), the former applies only to the popup menu.

Is there a way to change the background of an option menu in tkinter?

Okay everyone I found out how to do it by printing the option menu's config and looking through all the parameters. Turns out I had to add this:

<widget ref>.config(bg = "gray", highlightthickness = 0)

Theming Android's Options Menu

<item name="popupMenuBackground">?themeColorPrimary</item>

As simple as it is!

If you like to use a style, use:

<item name="popupMenuStyle">@style/MyActionBar</item>

instead of:

<item name="android:popupMenuStyle">@style/MyActionBar</item>


Related Topics



Leave a reply



Submit