Appcompat Toolbar Not Showing With Navigation Drawer

前端 未结 1 817
小蘑菇
小蘑菇 2020-12-06 00:03

I am trying to configure the following in my app:

  • Toolbar (Appcompat v7 version)
  • Navigation Drawer
  • Pre-Lollipop Appcompat v7 Materia
相关标签:
1条回答
  • 2020-12-06 00:16

    DrawerLayout extends FrameLayout, but you are treating it like a LinearLayout. You can either wrap your tag and the following LinearLayout in another LinearLayout, or you can move your tag.

    Also, "fill_parent" is deprecated and maps to "match_parent" so you should just use the latter. You can also remove the additional xmlns attributes in your LinearLayout element.

    <android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
    
        <LinearLayout
            android:id="@+id/layout_main"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
    
                <!-- Toolbar -->
                <include layout="@layout/toolbar"/>
                ...
    

    Your original layout did not work because the Toolbar was hidden (z-ordered) behind the LinearLayout.

    0 讨论(0)
提交回复
热议问题