With Linear, Frame and Relative layouts everything worked. But with DrawerLayout problems:
- the header of the toolbar leaves the toolbar. With gravity: center_vertical | start - the header is located in the center of the screen, and not in the center of the toolbar. On the screen set gravity: top. Title is aligned with the root layout, not with the toolbar.
- The toolbar has stopped working. Accepts the background color of the overall theme of the application.
toolbar.xml
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar_action" android:layout_height="45dp" android:layout_width="match_parent" android:background="@color/toolbar" android:gravity="top" app:titleTextColor="@color/title"> </android.support.v7.widget.Toolbar> activity_main.xml
<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"> <include layout="@layout/toolbar" /> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" /> <ListView android:id="@+id/left_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:choiceMode="singleChoice" android:divider="@color/toolbar" android:dividerHeight="1dp" android:listSelector="@drawable/list_selector" android:background="@color/drawer_menu_background"/> </android.support.v4.widget.DrawerLayout> MainActivity.java - the section where the toolbar is installed
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = findViewById(R.id.toolbar_action); toolbar.setNavigationIcon(R.drawable.burger); setSupportActionBar(toolbar); 