Search code examples
androidandroid-layoutnavigation-drawerandroid-navigationview

Navigation hamburger not visible below Lollipop


I have a navigation drawer activity. The hamburger and the settings button is visible in Lollipop, but not visible in versions below lollipop. However, if I touch that area, it's working fine, it's just, not visible.

My xml code:

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

The ScreenShot of lollipop:

Lollipop screen shot

The Screenshot of non(below)-lollipop

Below Lollipop screenshot


Solution

  •         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();