I am trying to migrate my android application which is using the png assets to icon fonts. I could successfully use it in navigation drawer using a list view. But I couldn't use it in navigation view by specifying it in the xml file of the menu.
This is what I got when I tried with Navigation Drawer
I don't know how will I use icon fonts in navigation view
to get those marked icons.
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_apple"
android:icon="@drawable/ic_menu_apple"
android:title="Apple" />
<item
android:id="@+id/nav_chrome"
android:icon="@drawable/ic_menu_chrome"
android:title="Orange" />
<item
android:id="@+id/nav_left"
android:icon="@drawable/ic_menu_left"
android:title="Grapes" />
</group>
How can I set those icons using icon font in this menu?
You need to set textView.setTypeface
where textView is item in your Navigation drawer. Also you need to have custom font with icons, put in to assets and then use it in code:
Typeface t = Typeface.createFromAsset(c.getAssets(), assetPath);
textView.setTypeface(t);
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