How to resize menu text
I tried changing the style as follows:
<item name="android:actionMenuTextAppearance">@style/MenuTextStyle</item> <stylename="MenuTextStyle"parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Menu"> <item name="android:textColor">@android:color/white</item> <item name="android:textSize">16sp</item> </style> But it worked. Sorry for my English. If you know this, please tell me. Thank you in advance!
In your application theme add the following element:
<item name="android:actionMenuTextAppearance">@style/customActionBar</item> Then define customActionBar as follows:
<style name="customActionBar" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Menu"> <item name="android:textSize">16sp</item> </style> Here you should get the text from MenuItems in SpannableStrings in onCreateOptionsMenu, change the text size compared to the default value through RelativeSizeSpan. If you want to enter the absolute font size, use AbsoluteSizeSpan, for example. up to 18 dpi = AbsoluteSizeSpan (18, true):
public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater infl = getMenuInflater(); infl.inflate(R.menu.menu_main, menu); for(int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); SpannableString spanString = new SpannableString(menu.getItem(i).getTitle().toString()); int end = spanString.length(); spanString.setSpan(new RelativeSizeSpan(1.5f), 0, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); item.setTitle(spanString); } return true; }