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 also take a look at SlidingDrawer class. It's a deprecated class, but as the documentation says you can write your own implementation based on its source code.
Because all these answers did not work on OS 6.0.1, I'll post here the solution that worked for me in combination with
DrawerLayout
+NavigationView
.So all what I do is change the width of the
NavigationView
programatically:This works for all screen sizes.