I am trying Material theme and changing the background and text color of Menu and items. Using the below style it works fine on the Toolbar, but the menu pop up while pressing device menu button shows no change in text color though the background got changed. Please help to change the text color as mentioned.
<resources>
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColorPrimary">@color/accent</item>
<item name="android:textColorSecondary">@color/accent</item>
<item name="android:textColorHint">@color/accent</item>
<!-- Menu Items -->
<item name="android:textColor">@color/accent</item>
<item name="android:actionMenuTextColor">@color/accent</item>
<item name="actionMenuTextColor">@color/accent</item>
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="android:itemBackground">@color/colorPrimaryDark</item>
<item name="android:itemTextAppearance">@style/MyActionBar.MenuTextStyle</item>
<!-- Menu Items -->
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">@color/colorPrimaryDark</item>
<item name="titleTextStyle">@style/MyActionBarTitle</item>
<item name="actionMenuTextColor">@color/accent</item>
</style>
<style name="MyActionBarTitle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/accent</item>
<item name="android:actionMenuTextColor">@color/accent</item>
<item name="actionMenuTextColor">@color/accent</item>
</style>
<style name="MyActionBar.MenuTextStyle">
<item name="android:textColor">@color/accent</item>
<item name="android:textStyle">bold</item>
<item name="android:actionMenuTextColor">@color/accent</item>
<item name="actionMenuTextColor">@color/accent</item>
</style>
try this create this theme
<style name="TextAppearance" parent="@style/Theme.Sherlock.Light">
<item name="actionMenuTextColor">@color/white</item>
<item name="android:actionMenuTextColor">@color/white</item>
</style>
than apply this theme in your Activity theme like this
<style name="your_theme" parent="your_parent">
<item name="android:itemTextAppearance">@style/TextAppearance</item>
</style>
or try this
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.your_menu, menu);
int positionOfMenuItem = 0;
MenuItem item = menu.getItem(positionOfMenuItem);
SpannableString s = new SpannableString("My red MenuItem");
s.setSpan(new ForegroundColorSpan(Color.RED), 0, s.length(), 0);
item.setTitle(s);
}
One simple line in your theme :)
<item name="android:actionMenuTextColor">@color/your_color</item>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With