Android OptionsMenu issue, background is always transparent

大兔子大兔子 提交于 2020-01-04 05:15:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!