It is necessary to make the following separators, as in the screenshot:

enter image description here

Numbered 1 from the logo red line.

Numbered 2 between "Settings" and "Rate app".

If at the expense of the first item I don’t even know about how to do it, then I tried the following markup with the second one:

<menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="single"> <item android:id="@+id/nav_camera" android:icon="@drawable/recent_activity" android:title="Your recent activity" /> <item android:id="@+id/nav_gallery" android:icon="@drawable/recent_suggestion" android:title="Recent suggestion" /> <item android:id="@+id/nav_slideshow" android:icon="@drawable/suggest_term_drawer" android:title="Suggest term" /> <item android:id="@+id/nav_manage" android:icon="@drawable/settings" android:title="Settings" /> <item android:title=""></item> <menu> <item android:id="@+id/nav_share" android:icon="@drawable/rate_app" android:title="Rate app" /> <item android:id="@+id/nav_send" android:icon="@drawable/feedback" android:title="Feedback" /> <item android:id="@+id/share" android:icon="@drawable/share" android:title="Share" /> </menu> </group> </menu> 

However, it turned out that there were distances from the separator from the bottom and from the top in approximately 1 item.

Here is the markup of the logo:

 <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:longClickable="false" android:scaleType="fitCenter" android:src="@drawable/logo_menu"/> 

1 answer 1

Create navigation_header.xml :

 <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="80dp"> //можно и свое расстояние задать <ImageView android:id="@+id/logo" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" android:src="@drawable/logo_menu"/> </FrameLayout> 

In the NavigationView markup, add the app:headerLayout="@layout/navigation_header" .

 <android.support.design.widget.NavigationView android:id="@+id/navigation_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:headerLayout="@layout/navigation_header" app:itemIconTint="#2196F3" app:itemTextColor="#2196F3" ... app:menu="@menu/navigation_items"/> 

In Activity , where the NavigationView add more:

 View headerView = LayoutInflater.from(this).inflate(R.layout.navigation_header, navigation, false); if (navigation != null) navigation.addHeaderView(headerView); ImageView logo = (ImageView) headerView.findViewById(R.id.logo); 

And indented solution here

  • does not find addHeaderView() method - Silento
  • @Asgard NavigationView navigation using? ekmakarek. Forgot to say in the markup NavigationView add app:headerLayout="@layout/navigation_header" I'm wildly sorry! Corrected the answer. Now it should definitely work! - iFr0z
  • @Asgard no more problems? helped?) - iFr0z
  • I apologize for the ignore, put in the hospital and just returned. As soon as I do something, I'll write about the result, thank you - Silento
  • @Asgard is good :) - iFr0z