I am begineer. I want to know , How to add a Item inside Navigation Drawer
which icon will be add right side of Item Title.
Exactly I want to do like this picture.
But how? I want to add item exactly like this Youtube Item.
This is Navigation Drawer
Menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Social Links">
<menu>
<item
android:id="@+id/nav_facebook"
android:icon="@drawable/ic_menu_facebook"
android:title="Facebook"
/>
<item
android:id="@+id/nav_youtube"
android:icon="@drawable/ic_menu_youtube"
android:title="Youtube"
/>
<item
android:id="@+id/nav_twitter"
android:icon="@drawable/ic_menu_twitter"
android:title="Twitter"
/>
</menu>
</item>
</menu>
I also attached this code in Manifest
:
android:supportsRtl="true"
Under res layout folder, create a layout named menu_image.xml. This layout is used to render image next to YouTube label.
menu_image.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:layout_width="6dp"
android:layout_height="6dp"
android:background="@drawable/addyourimage"></LinearLayout>
</LinearLayout>
Activity:
navigationView.getMenu().getItem(5).setActionView(R.layout.menu_image);
More Referencer
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