在Lollipop下面看不到导航汉堡包

时间:2016-02-04 07:12:36

标签: android android-layout android-navigation-drawer android-navigationview

我有一个导航抽屉活动。 汉堡包和设置按钮在Lollipop中可见,但在棒棒糖下面的版本中不可见。但是,如果我触摸该区域,它工作正常,它只是,不可见。

我的xml代码:

  1. app_bar_nav

    <?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".activities.Home">
    
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">
    
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />
    
    </android.support.design.widget.AppBarLayout>
    
    <include layout="@layout/content_home_nav" />
    
    
      </android.support.design.widget.CoordinatorLayout>
    
  2. 2.content_nav

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:background="@drawable/home_background"
    tools:showIn="@layout/app_bar_home_nav"
    android:weightSum="3">
    
       <RelativeLayout
       android:layout_width="match_parent"
       android:layout_height="0dp"
       android:layout_weight="1">
    
      </RelativeLayout>
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:weightSum="3">
    
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_margin="15dp"
            android:src="@drawable/home_reminders"
            android:layout_height="wrap_content"
            android:id="@+id/imageView_home_reminders" />
    
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_margin="15dp"
            android:src="@drawable/home_orders"
            android:layout_height="wrap_content"
            android:id="@+id/imageView_home_orders" />
    
        <ImageView
            android:layout_width="0dp"
            android:layout_weight="1"
            android:src="@drawable/home_vitals"
            android:layout_margin="15dp"
            android:layout_height="wrap_content"
            android:id="@+id/imageView_home_vitals" />
    </LinearLayout>
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
    
    </RelativeLayout>
    </LinearLayout>
    

    3.activity_nav

       <?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"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:openDrawer="start">
    
        <include
            layout="@layout/app_bar_home_nav"
            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"
            android:fitsSystemWindows="true"
            app:itemTextColor="#000000"
            app:menu="@menu/activity_home_nav_drawer" />
    
    </android.support.v4.widget.DrawerLayout>
    

    棒棒糖的ScreenShot:

    Lollipop screen shot

    非(下方)-lollipop

    的屏幕截图

    Below Lollipop screenshot

1 个答案:

答案 0 :(得分:0)

        final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawerLayout, toolbar, R.string.abc_action_bar_home_description, R.string.abc_action_bar_home_description) {
            @Override
            public void onDrawerSlide(View drawerView, float slideOffset) {
                super.onDrawerSlide(drawerView, slideOffset);
            }
        };
        drawerLayout.setDrawerListener(toggle);
        toggle.syncState();