I am using Navigation Drawer menu without the header. The first item in the menu is too close to the top bar. How can I create margin for the first item? I am using this drawer menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Home"
android:id="@+id/nav_item_home"
android:icon="@drawable/ic_home_black_24dp"/>
<item android:title="Search Definitions"
android:id="@+id/nav_item_search"
android:icon="@drawable/ic_search_black_24dp"/>
<item android:title="About">
<menu>
<item android:title="About this app"
android:id="@+id/nav_item_about"
android:icon="@drawable/ic_info_black_24dp"/>
<item android:title="How to use this app"
android:id="@+id/nav_item_howtouse"
android:icon="@drawable/ic_perm_device_information_black_24dp"/>
</menu>
</item>
The outcome is this:

What I did as a workaround is to wrap the first item in a item menu with a blank title ... like this:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="">
<menu>
<item android:title="Home"
android:id="@+id/nav_item_home"
android:icon="@drawable/ic_home_black_24dp"/>
<item android:title="Search Definitions"
android:id="@+id/nav_item_search"
android:icon="@drawable/ic_search_black_24dp"/>
</menu>
</item>
<item android:title="About">
<menu>
<item android:title="About this app"
android:id="@+id/nav_item_about"
android:icon="@drawable/ic_info_black_24dp"/>
<item android:title="How to use this app"
android:id="@+id/nav_item_howtouse"
android:icon="@drawable/ic_perm_device_information_black_24dp"/>
</menu>
</item>
And then the outcome is exactly what I wanted:

Can someone please confirm if this workaround is the only way or is there any correct way of achieving the desired output.
Bit late, but any solution?
I've just played around in the xml:
<android.support.design.widget.NavigationView>
...
android:layout_marginTop="?attr/actionBarSize"
android:paddingTop="somePaddingValueInSp"
...
/>
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