For a navigationview
, we can create a divider between two items by putting them in two groups. But how can we create a divider between a header and menu? I tried to make an empty group at the top of the menu, but it doesn't work.
The default theme for navigationview
looks quite cool, but I like the black & white style. But it looks quite awkward when I can't create a divider between the header and menu (sad)
I don't know what's the proper way to do it, but I have some workaround for it:
As mentioned by P. Ilyin, you can put the divider on the bottom of your header view.
You can add the divider onto the NavigationView layout, and manually adjusting the divider position.
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 make a custom gray line divider that has 1dp height, and it positioned under the menu header (140dp is the height of this menu header).
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