I'd like to create a full width navigation drawer. Setting layout_width
to match_parent
on @+id/left_drawer
yields in width of about 80% of screen space. This seems to be the standard behavior. Do I have to override onMeasure()
of DrawerLayout
?
My current code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:id="@+id/mainFragmentContainer">
</FrameLayout>
<include
android:id="@+id/left_drawer"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
layout="@layout/drawer"/>
</android.support.v4.widget.DrawerLayout>
Thanks.
You can use this. Inspired by this post, I've upgraded for the 5th edition. Because it was having problems with StatusBar in versions 5 and later.
you have to extend DrawerLayout and override some methods because MIN_DRAWER_MARGIN is private
you can by below code
That's works perfectly for me. Hope help others.
If you want simpler solution you can just set negative margin
for your left_drawer:
Google recommends having a maxim width of 320 dip as per the UI guidelines here. Moreover, the width can be set by specified the layout_width of the left_drawer ListView.