10

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?

James Parsons
  • 6,097
  • 12
  • 68
  • 108

1 Answers1

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