Cómo configurar el juego de cajones debajo de la barra de herramientas con el diseño del coordinador

Tengo un xml como este, cuando muestro el diseño del cajón, se superpone a la Toolbar , quiero que mi cajón debajo de mi Toolbar , no puedo averiguar cómo hacerlo, he probado muchas cosas y lo probé todo el día. ¿Cómo puedo utilizar CoordinatorLayout con DrawerLayout sin superponer la Toolbar ?

Este es mi estilo de barra de acción:

 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/ColorPrimary</item> <item name="colorPrimaryDark">@color/ColorPrimaryDark</item> <item name="colorAccent">@color/ColorPrimary</item> </style> 

Este es mi diseño:

 <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout android:id="@+id/drawerLayout" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:elevation="0dp"> <android.support.v7.widget.Toolbar android:id="@+id/toolBar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/ColorPrimary" app:layout_scrollFlags="scroll|enterAlways" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <TextView android:id="@+id/toolBarTv" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/app_name" android:textColor="@color/white" android:textSize="18dp"/> </android.support.v7.widget.Toolbar> </android.support.design.widget.AppBarLayout> <FrameLayout android:id="@+id/frameLayout" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"/> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|bottom" android:layout_marginBottom="10dp" android:layout_marginRight="10dp" app:elevation="4dp" app:fabSize="normal" app:layout_behavior="com.frt.poppcar.utils.FabBehavior"/> </android.support.design.widget.CoordinatorLayout> <ScrollView android:id="@+id/drawerList" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="left|start" android:background="@color/white"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/mainTv" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/main" android:textColor="@color/five" android:textSize="18dp"/> </LinearLayout> </ScrollView> </android.support.v4.widget.DrawerLayout> 

Esto funciona para mí muy bien .. u necesidad de tener el diseño del coordinador como el diseño de los padres y el comportamiento de la disposición del conjunto de ur cajón de diseño

 <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> </android.support.design.widget.AppBarLayout> <!-- to make toolbar scroll and hide towards upside include this line app:layout_behavior="@string/appbar_scrolling_view_behavior"--> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_marginTop="?attr/actionBarSize" android:layout_width="match_parent" android:layout_height="match_parent"> <!--<include layout="@layout/navigation_drawer_content"/>--> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:headerLayout="@layout/nav_header" app:menu="@menu/drawer_view" /> </android.support.v4.widget.DrawerLayout> </android.support.design.widget.CoordinatorLayout> 

En primer lugar, no se recomienda hacer esto debido a Material Design Style Guide
Entonces, deberías definir android:minHeight="?attr/actionBarSize" en la barra de herramientas Layout primero. Después de que definen android:layout_marginTop="?attr/actionBarSize" en su diseño NavigationView. Es una especie de truco.

Pienso que es demasiado atrasado pero usted puede querer saber cuál era el problema o lo que usted podría hacer. De todos modos.

La nueva Support Design Library incluyó NavigationDrawer que se podría utilizar como esta respuesta: https://stackoverflow.com/a/34921695/4409113

 <!-- The navigation drawer --> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:menu="@menu/activity_main_drawer" /> 

Y esto debería funcionar ahora después de agregar y editar algunos errores:

 <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawerLayout" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.CoordinatorLayout android:id="@+id/root_coorinator" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/toolBar" android:layout_width="match_parent" android:layout_height="?actionBarSize" app:layout_scrollFlags="scroll|enterAlways" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <TextView android:id="@+id/toolBarTv" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/app_name" android:textSize="18dp" /> </android.support.v7.widget.Toolbar> </android.support.design.widget.AppBarLayout> <FrameLayout android:id="@+id/frameLayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginEnd="10dp" app:elevation="4dp" app:fabSize="normal" app:layout_anchor="@id/root_coorinator" app:layout_anchorGravity="bottom|end|right" /> </android.support.design.widget.CoordinatorLayout> <!--<ScrollView android:id="@+id/drawerList" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="left|start"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/mainTv" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="main" android:textSize="18dp" /> </LinearLayout> </ScrollView>--> <!--Don't use it like that, Use NavigationDrawer instead--> </android.support.v4.widget.DrawerLayout> 

Y una cosa más, usted podría utilizar esa Toolbar sí sola sin añadir que TextView como un título.

Además, puede utilizar ese diseño dentro de NestedScrollView .

  • Cambiar el color del texto del menú de opciones cuando usamos app: showAsAction = "always"
  • Los subtítulos de la barra de herramientas no aparecen
  • Cómo alinear el icono en el lado izquierdo de la barra de aplicaciones en android
  • Barra de herramientas de acceso (y sus hijos) de fragmento?
  • Cambiar el menú de la barra de herramientas Color del elemento (acción no oculta)
  • ¿Cómo puedo utilizar un icono en lugar de un título en la barra de herramientas de Android?
  • ¿Cómo hacer que el menú emergente de desbordamiento evite obstruir la barra de acción?
  • Barra de herramientas: botón de menú de desbordamiento siempre mostrando
  • ¿Cómo mantener visible la barra de herramientas con adjustPan?
  • CollapsingToolbarLayout setTitle () no se actualiza a menos que se colapse
  • Barra de herramientas android muestra medio contenido
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.