简体   繁体   English

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

[英]Why does my navigation drawer doesn't appear?(only the hamburger icon)

hi i am doing a swipe tabs that if you swipe up the toolbar will hide now i am putting navigation drawer.My navigation drawer doesn't appear only the hamburger icon appeared. 嗨,我正在做一个滑动选项卡,如果您向上滑动,工具栏将立即隐藏,我正在放置导航抽屉。我的导航抽屉没有出现,只有汉堡包图标出现了。 but if i am going to put the close tag of my drawer under my view pager . 但是如果我要把抽屉的关闭标签放在视图传呼机下面。 the drawer will work perfectly but the list on my recycler-view will not be appeared. 抽屉可以正常工作,但是不会出现在我的回收者视图中的列表。 i think there's a problem on my xml or else mismatched placing of it. 我认为我的xml出现问题,否则放置不匹配。 any suggestions? 有什么建议么? here's my activity_main.xml 这是我的activity_main.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>

Try this: 尝试这个:

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

Try this: 尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM