这是我的style.xml
现在,当我点击选项菜单时。文字颜色显示为黑色。我需要把它改成白色
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/redDark</item>
<item name="colorPrimaryDark">@color/redLite</item>
<item name="colorAccent">@color/redDark</item>
<item name="actionMenuTextColor">@color/redDark</item>
</style>
答案 0 :(得分:1)
试试此代码
<item name="android:actionMenuTextColor">@color/your_color</item>
答案 1 :(得分:0)
您可以通过编程方式更改菜单项文本颜色。
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main_activity, menu);
for(int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);
SpannableString spanString = new SpannableString(menu.getItem(i).getTitle().toString());
spanString.setSpan(new ForegroundColorSpan(Color.GREEN), 0, spanString.length(), 0); //fix the color to white
item.setTitle(spanString);
}
return super.onCreateOptionsMenu(menu);
}
希望有所帮助:)
答案 2 :(得分:0)
检查是否有效
<item name="android:itemTextAppearance">@style/myMenuTextApearance</item>
并在样式
中添加此文本样式<style name="myMenuTextApearance" parent="@android:style/TextAppearance.Widget.IconMenu.Item">
<item name="android:textColor">@android:color/primary_text_dark</item>
</style>