[英]how to change background color of menu using ActionBarSherlock
I am trying to change the background color of my menu and still get the same result. 我试图更改菜单的背景颜色,但仍然得到相同的结果。 I want to set my menu to white background. 我想将菜单设置为白色背景。 my menu looks like that 我的菜单看起来像这样
<item
android:id="@+id/exit"
android:icon="@drawable/exit"
android:orderInCategory="1"
android:title="exit">
</item>
<item
android:id="@+id/about"
android:icon="@drawable/get_info"
android:title="about">
</item>
and my style looks like that 我的风格是这样的
<resources>
<style name="AppTheme" parent="android:Theme.Light" />
</resources>
and the code is: 代码是:
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.menu, menu);
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.submenu, menu);
return super.onCreateOptionsMenu(menu);
}
and I want that my menu background will be white and not as default of android style. 我希望我的菜单背景为白色,而不是默认的android样式。
change the actionBar background like this: 像这样更改actionBar背景:
View actionBarView = getLayoutInflater().inflate(R.layout.action_bar_custom_view, null);
actionBar.setCustomView(actionBarView);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.