Deepak Rattan
Deepak Rattan

Reputation: 1299

Navigation Drawer (SlidingMenu) is not working properly

I'm using DrawerLayout in my Activity .xml is given below :

 <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- The first child in the layout is for the main Activity UI-->
    <RelativeLayout 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:orientation="vertical">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:background="#09436B"
            android:elevation="6dp"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/tab_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/toolbar"
            android:background="#F1F1F1"
            android:elevation="6dp"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:tabGravity="fill"
            app:tabMode="fixed"
            app:tabSelectedTextColor="@color/tab_selected_text_color"
            app:tabTextColor="@color/tab_text_color" />


        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/tab_layout"></android.support.v4.view.ViewPager>

    </RelativeLayout>

    <!-- Side navigation drawer UI -->
    <LinearLayout
        android:id="@+id/layout_navigation_drawer"
        android:layout_width="200dp"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <com.almabay.almachat.circularImageView.CircularImageView
                android:id="@+id/imgUser"
                android:layout_width="100dp"
                android:layout_height="100dp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/txtNameUser"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

                <TextView
                    android:id="@+id/txtEmaiIDUser"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
            </LinearLayout>
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/margin10"></View>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/txtProfile"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/profile" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/txtAccount"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/accounts" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/txtNotification"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/notification" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/txtContacts"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/contacts" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/txtChats"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/chats" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/txtHelp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/help" />
        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/margin10" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/txtLogout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/logout" />
        </LinearLayout>
    </LinearLayout>

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

But I'm getting the correct Navigation drawer.No hamburger icon is shown

ScreenShot

I want to implement the following screen:

Scree to implement

Please guide me where i am doing mistake.I know that inside DrawerLayout one view is for the main content of the screen and other is for Navigation Drawer items.I have studied various examples which shows i have to use the list view for the items of navigation drawer but i can not use list view here as i have to fix my design .

Upvotes: 0

Views: 50

Answers (1)

theMatus
theMatus

Reputation: 163

I would suggest you to use navigation view (put it on the bottom of drawer layout) and put your items in it.

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start">

    <include layout="@layout/your navigation view layout"/>

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

Upvotes: 1

Related Questions