I am making an app that will feature a Navigation Drawer. My computer cannot run the AVD emulator. Even with a minimal AVD, I have waited hours and it did not start up. That being said, I have had to rely on the Android Studio designer to see what the app will look like. When creating a Navigation Drawer activity, is there some way I can toggle it being open on the designer?
Asked
Active
Viewed 3,111 times
10
-
Just preview your drawer fragment – tachyonflux Jun 08 '15 at 00:12
-
And it will show the overlay over the main view? – James Parsons Jun 08 '15 at 01:00
-
I guess you could also just temporarily change your `DrawerLayout` to a `RelativeLayout`. – tachyonflux Jun 08 '15 at 02:04
-
Possible duplicate of [See navigation drawer preview](http://stackoverflow.com/questions/29368885/see-navigation-drawer-preview) – Shirish Herwade Mar 14 '17 at 12:24
1 Answers
25
I found that you can add tools:openDrawer="start"
to your DrawerLayout
.
Like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout android:id="@+id/drawer"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:openDrawer="start">
<!-- your content include -->
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/drawer"/>
</android.support.v4.widget.DrawerLayout>
Demo:
not really perfect, but it's enough!

gustavohenke
- 40,997
- 14
- 121
- 129
-
somehow it works, thanks. But gives NullPointerException for the line - 'ActionBarDrawerToggle..syncState();' in overrided 'onPostCreate()' method, so I needed remove that tools:openDrawer="start" line after design complete – Shirish Herwade Mar 14 '17 at 13:58