I have the following Android Java and XML code. I want to change the font of Menu Items of my app. I know only that we can change the font of TextView using setTypeface but not able to find anyway for Menu Item.
JAVA Code-:
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_refresh1: Toast.makeText(this, "Item1 Selected", Toast.LENGTH_SHORT) .show(); break; case R.id.action_refresh2: Toast.makeText(this, "Item2 Selected", Toast.LENGTH_SHORT) .show(); break; default: break; } }
XML Code-:
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_refresh1" android:orderInCategory="100" android:showAsAction="always" android:title="Item1"/> <item android:id="@+id/action_refresh2" android:orderInCategory="100" android:showAsAction="always" android:title="Item2"/> </menu>
I want to change the font of two menu item , but don't know how to integrate settypface for Menu Item.
The menu for changing the font is in the Home tab near the top-left corner. Like the font size menu, hovering your mouse over each font option will change selected text so you can see a preview of what each font looks like. If you already know what font you want, you can start typing the name to skip to it in the menu.
Create Style in styles.xml
<style name="Style_TextView"> <item name="fontFamily">@font/myriadproregular</item> </style>
Add Below code into android.support.design.widget.NavigationView
app:itemTextAppearance="@style/Style_TextView"
Note: It works for android.support.design.widget.NavigationView
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