问题
My options menu always shows no background (background is transparent). Does anyone know how to ged rid of this?
My activity where the fail is originated, extends from another custom activity.
I had this project on eclipse and the optionsmenu worked normally, but since I migrated to AndroidStudio, the options menu is always transparent. I've tried to change the menu's xml, and create the menu programatically, but the background still transparent.
回答1:
Probably too late, but in case people people end up here via Google (like me).
Theme.AppCompat
sets android:panelBackground
to @android:color/transparent
, which is normally not a problem as if you extend ActionBarActivity
it handles the options panel creation with a background. However if you are using a standard Activity, with Theme.AppCompat
, the options menu will be transparent. Fix by either changing the android:panelBackground
or extending ActionBarActivity
. Probably extending ActionBarActivity
.
来源:https://stackoverflow.com/questions/27787890/android-optionsmenu-issue-background-is-always-transparent