Creating an activity with navigation drawer in Android Studio causes this to be shown in the XML code:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
If I remove the tools:openDrawer="start"
, on the layout preview, the navigation drawer will be closed instead of open.
I thought this was a replacement attribute, similar to android:text
that can be replaced with tools:text
to put some placeholder text in the layout preview. But when I change it to android:openDrawer
or app:openDrawer
, the app can't be compiled because they are unknown attributes.
So I wonder how tools:openDrawer
works, and whether it is documented anywhere.
tools:openDrawer="start"
to yourDrawerLayout
in the preview screen in IDE screen will be shown with opened drawer. If you remove that line, screen will be shown with closed drawer.tools:...
attributes are used for previews only (showing some text, etc.). You've triedandroid
andapp
because you wanted to open drawer on screen enter or just curious? – Cachou