简体   繁体   English

我可以在Android Studio中预览打开的导航抽屉吗?

[英]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. 我的电脑无法运行AVD仿真器。 Even with a minimal AVD, I have waited hours and it did not start up. 即使AVD很小,我也等了好几个小时才启动。 That being said, I have had to rely on the Android Studio designer to see what the app will look like. 话虽这么说,我不得不依靠Android Studio设计师来看看应用程序的外观。 When creating a Navigation Drawer activity, is there some way I can toggle it being open on the designer? 在创建导航抽屉活动时,有什么方法可以切换它在设计器上打开吗?

I found that you can add tools:openDrawer="start" to your DrawerLayout . 我发现你可以添加tools:openDrawer="start"到你的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! 不是很完美,但这已经足够了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM