EditText inside DrawerLayout

I am trying to set the EditText window inside DrawerLayout, but after carefully reading the Android Training Website , they explain that DrawerLayout is allowed to have only two child views. If I would like to do something like the following code, how do I approach it?

<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"> <!-- The main content view --> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" /> <!-- The navigation drawer --> <EditText android:id="@+id/EditText01" android:layout_width="240dp" android:layout_height="match_parent" android:hint="Search" > </EditText> <ListView android:id="@+id/left_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" android:background="#111"/> </android.support.v4.widget.DrawerLayout> 
+4
source share
1 answer

Do it like this:

 <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"> <!-- The main content view --> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" /> <!-- The navigation drawer --> <LinearLayout android:id="@+id/left_drawer" android:layout_height="wrap_content" android:layout_width="240dp" android:orientation="vertical" android:layout_gravity="start" > <EditText android:id="@+id/EditText01" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Search" > </EditText> <ListView android:id="@+id/left_drawer_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" android:background="#111"/> </LinearLayout> </android.support.v4.widget.DrawerLayout> 

In other words, no matter what happens in the first view, it will be set as a view of the content, and no matter what second view will be installed in the box. So just add the elements to the second view for the box and first for the content. Greetings :)

+13
source

Source: https://habr.com/ru/post/1489965/


All Articles