为什么我的导航抽屉没有出现?(只有汉堡包图标)

时间:2016-02-25 03:26:19

标签: java android xml android-layout navigation-drawer

嗨,我正在做一个滑动标签,如果你向上滑动工具栏将隐藏现在我正在放置导航抽屉。我的导航抽屉不会出现只有汉堡包图标出现。但是,如果我要把我的抽屉的标签放在我的浏览器下面。抽屉将完美地工作,但我的回收器视图上的列表将不会出现。我认为我的xml存在问题,或者它的放置不匹配。有什么建议?这是我的activity_main.xml

activity_main.xml中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    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:fitsSystemWindows="true"
    android:orientation="vertical">


    <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/coordinatorLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">


        <android.support.v4.widget.DrawerLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:id="@+id/drawerLayout"
            >

            <FrameLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/containerView">
            </FrameLayout>

            <android.support.design.widget.NavigationView
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="start"
                android:id="@+id/shitstuff"
                app:itemTextColor="@color/black"
                app:menu="@menu/drawermenu"
                android:layout_marginTop="-24dp" />

        </android.support.v4.widget.DrawerLayout>
        <!-- AppBar Layout   -->
        <android.support.design.widget.AppBarLayout

            android:id="@+id/appBarLayout"
            android:layout_width="fill_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="fill_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                android:title="Android Testing"/>
            <!-- Tab Layout for creating tabs -->
            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                app:tabGravity="fill"
                app:tabMode="fixed"
                android:background="@color/material_blue_grey_800"
                app:tabIndicatorColor="@color/main_color"
                app:tabSelectedTextColor="@color/main_color"
                app:tabTextColor="@color/white"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

            </android.support.design.widget.TabLayout>
        <!-- Helps handing the Fragments for each Tab -->
        </android.support.design.widget.AppBarLayout>

        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    </android.support.design.widget.CoordinatorLayout>

</LinearLayout>

2 个答案:

答案 0 :(得分:0)

试试这个:

    <?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"
    >

    <LinearLayout
        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:fitsSystemWindows="true"
        android:orientation="vertical">


        <android.support.design.widget.CoordinatorLayout android:id="@+id/coordinatorLayout"
                                                         xmlns:android="http://schemas.android.com/apk/res/android"
                                                         xmlns:app="http://schemas.android.com/apk/res-auto"
                                                         android:layout_width="fill_parent"
                                                         android:layout_height="fill_parent">


            <FrameLayout
                android:id="@+id/containerView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
            </FrameLayout>

            <android.support.design.widget.AppBarLayout

                android:id="@+id/appBarLayout"
                android:layout_width="fill_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="fill_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="?attr/colorPrimary"
                    android:title="Android Testing"
                    app:layout_scrollFlags="scroll|enterAlways"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
                <!-- Tab Layout for creating tabs -->
                <android.support.design.widget.TabLayout
                    android:id="@+id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/material_blue_grey_800"
                    app:tabGravity="fill"
                    app:tabIndicatorColor="@color/main_color"
                    app:tabMode="fixed"
                    app:tabSelectedTextColor="@color/main_color"
                    app:tabTextColor="@color/white">

                </android.support.design.widget.TabLayout>
                <!-- Helps handing the Fragments for each Tab -->
            </android.support.design.widget.AppBarLayout>

            <android.support.v4.view.ViewPager
                android:id="@+id/viewPager"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

        </android.support.design.widget.CoordinatorLayout>

    </LinearLayout>


    <android.support.design.widget.NavigationView
        android:id="@+id/shitstuff"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:layout_marginTop="-24dp"
        app:itemTextColor="@color/black"
        app:menu="@menu/drawermenu"/>

</android.support.v4.widget.DrawerLayout>

答案 1 :(得分:0)

试试这个:

<?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:id="@+id/coordinatorLayout"                                                  
          android:layout_width="fill_parent"
          android:layout_height="fill_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="fill_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="fill_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:title="Android Testing"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
            <!-- Tab Layout for creating tabs -->
            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/material_blue_grey_800"
                app:tabGravity="fill"
                app:tabIndicatorColor="@color/main_color"
                app:tabMode="fixed"
                app:tabSelectedTextColor="@color/main_color"
                app:tabTextColor="@color/white">

            </android.support.design.widget.TabLayout>
            <!-- Helps handing the Fragments for each Tab -->
        </android.support.design.widget.AppBarLayout>
        <FrameLayout
            android:id="@+id/containerView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
        </FrameLayout><!-- need attention -->

        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>         <!-- need attention -->

    </android.support.design.widget.CoordinatorLayout>

</LinearLayout>


<android.support.design.widget.NavigationView
    android:id="@+id/shitstuff"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:layout_marginTop="-24dp"
    app:itemTextColor="@color/black"
    app:menu="@menu/drawermenu"/>

</android.support.v4.widget.DrawerLayout>