How can I use the icons in the navigation menu using the font icon in android

I am trying to port an android application that uses png resources for icons. I could successfully use it in the navigation box using the list view. But I could not use it in navigation mode, specifying it in the XML menu file.

This is what I got when I tried using Navigation Drawer

When I tried with the navigation box

I do not know how to use the icons in the navigation view to get the 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 to set these icons using the icon in this menu?

+6
source share
3 answers

You need to set textView.setTypeface , where textView is the item in your navigation box. You also need to have your own font with icons, paste it into assets and then use it in code:

Typeface t = Typeface.createFromAsset(c.getAssets(), assetPath); textView.setTypeface(t);

+1
source

I'm not sure, but you can use an instance of the Textview element and install it in java.

0
source
 <android.support.design.widget.NavigationView android:id="@+id/navigation" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" android:background="@drawable/bg_all" app:itemIconTint="@android:color/white" app:itemTextColor="@android:color/white" app:theme="@style/list_item_appearance" app:menu="@menu/drawer_menu" > 
0
source

All Articles