Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This will work if you move both the <code>android:id="@+id/left_drawer"</code> (or create a new id) and set the gravity.</p> <p>The id move (or new one) is so the reference is correct so you call <code>closeDrawer()</code> on it and not the child views.</p> <p>But most importantly, the <code>DrawerLayout</code> requires that element to have a <code>android:layout_gravity</code> set on it, as you mentioned.</p> <p>Finally, you need to call close <code>closeDrawer()</code> on the base view, the one with the required gravity.</p> <p>Example:</p> <pre><code>&lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white"&gt; &lt;FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" /&gt; &lt;LinearLayout android:id="@+id/left_drawer" android:layout_width="320dp" android:layout_height="match_parent" android:layout_gravity="start" android:orientation="vertical"&gt; &lt;ImageView android:id="@+id/ivwLogo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/video_icon" /&gt; &lt;ListView android:id="@+id/left_drawer_child" android:layout_width="match_parent" android:layout_height="match_parent" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" android:background="@android:color/white" /&gt; &lt;/LinearLayout&gt; &lt;/android.support.v4.widget.DrawerLayout&gt; </code></pre> <p>In code:</p> <pre><code>DrawerLayout mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout) LinearLayout mDrawerLinear = (LinearLayout) findViewById(R.id.left_drawer); ListView mDrawerListChild = (ListView) findViewById(R.id.left_drawer_child); ... mDrawer.closeDrawer(mDrawerLinear); </code></pre> <p>(This is basically what @Karakuri posted, but with a more complete explanation and example.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload