0

In Android Studio when create a new project the Android Studio suggest Activity. in Navigation Drawer Activity i want the Drawer Toggle has shown but to Default mode it hidden under navigation.

enter image description here

enter image description here

This is my code:

setContentView(R.layout.activity_main); 
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); 
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 
drawer.setDrawerListener(toggle); 
toggle.syncState(); 

please help that change it to show drawer toggle...

bofredo
  • 2,348
  • 6
  • 32
  • 51
sadegh sarvi
  • 164
  • 4
  • 15
  • Please post your activity code – Rohit5k2 Feb 23 '16 at 14:30
  • this Default code my friend...: setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); – sadegh sarvi Feb 23 '16 at 14:40
  • 4
    See this http://stackoverflow.com/questions/26464326/how-do-i-make-drawerlayout-to-display-below-the-toolbar – Rohit5k2 Feb 23 '16 at 15:01

1 Answers1

1

I do changes in activity_main.xml


activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolBar"
        android:layout_width="match_parent"
        android:background="#adfcdd"
        android:layout_height="50dp"></android.support.v7.widget.Toolbar>
</LinearLayout>
    <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"
        android:fitsSystemWindows="true"
        tools:openDrawer="start">

        <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:headerLayout="@layout/nav_header_main"
            app:menu="@menu/activity_main_drawer" />

    </android.support.v4.widget.DrawerLayout>
</LinearLayout>
Usman
  • 339
  • 3
  • 15