I am using android compact library for building the action bar for both older and newer versions of android. so my requirement includes that i need to show action bar in blue color. now i have changed the action bar background color to blue , now i want to change the background color of popup menu which comes when we click on overflow icon. I tried in many ways but nothing is changing the background color.any one suggest me whether we can change the background color of popup menu using app-compact library or not, if we can please suggest me
Asked
Active
Viewed 3,942 times
0
-
http://jgilfelt.github.io/android-actionbarstylegenerator/ – Mr. N.V.Rao May 26 '14 at 06:44
-
@VenuRao This will work only if we are using sherlock library – AndroidDev May 26 '14 at 06:47
-
select theme for App Compact Light..i think u are using v7 compact lib – Mr. N.V.Rao May 26 '14 at 06:48
-
not working @Venu Rao – AndroidDev May 26 '14 at 07:02
-
Check this solution http://stackoverflow.com/questions/29095733/toolbar-pop-up-theme-android – Apurva Jul 28 '15 at 14:22
2 Answers
5
Add this to your toolbar element
app:popupTheme="@style/ThemeOverlay.YourApp"
Then in your styles.xml
define the popup menu style
<style name="ThemeOverlay.YourApp" parent="ThemeOverlay.AppCompat.Light">
<item name="android:colorBackground">@color/your_background_color</item>
<item name="android:textColor">@color/your_text_color</item>
</style>
Note that you need to use colorBackground
and never background
. The latter would be applied to everything (the menu itself and each menu item), the former applies only to the popup menu.
-
If you want to just change the color of the overflow menu, than set android:colorBackground to whatever you want, like @stackex suggested. Thanks a lot. – Zsolt Boldizsar Apr 08 '15 at 06:20
1
Use android:popupBackground
into styles.
like
<style name ="MyPopupMenu" parent="Theme.AppCompat.Light">
<item name="popupMenuStyle">@style/MyPopupMenuStyle</item>
</style>
<style name="MyPopupMenuStyle">
<item name="android:dropDownSelector">@drawable/abc_list_selector_holo_dark</item>
<item name="android:popupBackground">@drawable/abc_menu_dropdown_panel_holo_dark</item>
<item name="android:dropDownVerticalOffset">0dip</item>
<item name="android:dropDownHorizontalOffset">0dip</item>
<item name="android:dropDownWidth">wrap_content</item>
</style>

Pankaj Kumar
- 81,967
- 29
- 167
- 186
-
No pankaj its not working. here i should use only "@style/Theme.AppCompat.Light" theme. because i am using appcompact library for supporting both lower and higher versions. so using that theme i have to customize – AndroidDev May 26 '14 at 06:44
-
Then change `android:Theme.Holo.Light` with `Theme.AppCompat.Light` – Pankaj Kumar May 26 '14 at 06:47
-
Thanks for the help. but sorry it is changing the background of Drop down i mean action bar spinner. I need to change the background of menu which comes when we click on over flow menu icon. – AndroidDev May 26 '14 at 07:26
-
https://stackoverflow.com/a/64390171/1638277 for appcompat / material theme v21+ solution – avianey Oct 16 '20 at 13:35
-