Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I preview an open Navigation Drawer in Android Studio

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?

like image 432
James Parsons Avatar asked Jun 07 '15 23:06

James Parsons


1 Answers

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!

like image 187
gustavohenke Avatar answered Sep 21 '22 15:09

gustavohenke