[英]How to change color of menu in actionbar?
I want change background of menu and set it to blue. 我想要更改菜单的背景并将其设置为蓝色。 Now background of my menu is black.How to change this?
现在我的菜单背景为黑色。如何更改? Menu xml file :
菜单xml文件:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.nabege.AboutUsActivity" >
<item
android:id="@+id/help"
android:title="@string/help" />
<item
android:id="@+id/setting"
android:title="@string/setting"/>
Java codes : Java代码:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.about_us, menu);
return super.onCreateOptionsMenu(menu);
}
Put the following styles
in your styles.xml
将以下
styles
放入您的styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/primary_color</item>
<!--<item name="colorPrimaryDark">@color/primary_color</item>-->
<item name="colorAccent">@color/primary_color</item>
<item name="actionBarStyle">@style/AppThemeActionBarStyle</item>
</style>
<style name="AppThemeActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="background">@color/your_background_color</item>
</style>
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.