Android的工具栏溢出菜单文字的颜色和填充菜单屏幕 [英] Android toolbar overflow menu change text color and fill menu to the screen
本文介绍了Android的工具栏溢出菜单文字的颜色和填充菜单屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有
我面临的问题,改变工具栏/操作栏的溢出菜单项的文字颜色。我做了太多的google搜索和阅读#1的答案,但它不能解决我的prblem
I facing problem to change the text colour of toolbar/action bar overflow menu item. I do too many googling and reading Stackoverflow answers but it can not solve my prblem
currenlt我得到的黑色到溢出菜单项。
currenlt i am getting black colour into overflow menu item.
我想是 1.我想更改菜单项的黑到白的颜色。 2.我想改变溢出菜单的宽度相匹配父画面
what i want is 1. I want to change the colour of menu item black to WHITE. 2. I want to change the width of the overflow menu to match parent screen
我的code:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:textColorPrimary">@color/primary_text</item>
<item name="android:textColorSecondary">@color/secondary_text</item>
<item name="android:divider">@color/divider</item>
<item name="icon">@color/icons</item>
<item name="actionOverflowMenuStyle">@style/AppTheme.Base.PopupMenu</item>
</style>
<style name="AppTheme.Base.PopupMenu" parent="android:Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">@color/primary</item>
</style>
请,帮我解决这个问题。
Please, help me to solve this..
在此先感谢
推荐答案
我终于得到了code为转换黑色到白色
finally i got the code for the convert black colour to white
public boolean onPrepareOptionsMenu(Menu menu) {
//return super.onPrepareOptionsMenu(menu);
try {
for (int i = 0; i < menu.size(); i++) {
MenuItem mi = menu.getItem(i);
mi.setIcon(R.drawable.ic_action_new);
String title = mi.getTitle().toString();
Spannable spannable = new SpannableString(title);
spannable.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mi.setTitle(spannable);
}
} catch (Exception ex) {
}
return true;
}
这篇关于Android的工具栏溢出菜单文字的颜色和填充菜单屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文