Create a separator between title and menu in navigation mode for drawerlayout

With a navigationview we can create a separator between two elements by putting them in two groups. But how can we create a separator between the title and the menu? I tried to make an empty group at the top of the menu, but that would not work.

The default theme for navigationview looks pretty cool, but I like the black and white style. But it looks pretty uncomfortable when I cannot create a separator between the title and the menu (sad)

enter image description here

+5
source share
1 answer

I don’t know how to do it right, but I have a workaround:

  • As mentioned by P. Ilyin, you can put a separator at the bottom of your title.

  • You can add a separator to the NavigationView layout and manually adjust the position of the separator.

    Example:

     <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/drawer_menu_header" app:menu="@menu/menu_drawer"> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/background_gray" android:layout_marginTop="140dp"/> </android.support.design.widget.NavigationView> 

    In this case, we create our own gray line divider with a height of 1dp and position it under the menu heading (140dp is the height of this menu heading).

+1
source

All Articles