简体   繁体   中英

How to create left navigation drawer when top header logo is fixed and menu item is scrolling and show in category title?

I am new in android so please guide me How to create left navigation drawer when top header logo is fixed and menu item is scrolling and show in category title exact like this

I am trying this code

XML FIle is

My Navigation drawer is here - nav_header_main.xml and

menu file is in res/menu/

 <?xml version="1.0" encoding="utf-8"?>
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:title="Main Category"></item>
    <item
        android:id="@+id/nav_camera"
        android:icon="@drawable/ic_menu_camera"
        android:title="Import" />
    <item
        android:id="@+id/nav_gallery"
        android:icon="@drawable/ic_menu_gallery"
        android:title="Gallery" />
    <item
        android:id="@+id/nav_slideshow"
        android:icon="@drawable/ic_menu_slideshow"
        android:title="Slideshow" />
    <item
        android:id="@+id/nav_manage"
        android:icon="@drawable/ic_menu_manage"
        android:title="Tools" />

    <item android:title="Communicate">
    </item>

    <item
        android:id="@+id/nav_share"
        android:icon="@drawable/ic_menu_share"
        android:title="Share" />
    <item
        android:id="@+id/nav_send"
        android:icon="@drawable/ic_menu_send"
        android:title="Send" />

    <item
        android:id="@+id/nav_slideshow1"
        android:icon="@drawable/ic_menu_slideshow"
        android:title="Slideshow" />
    <item
        android:id="@+id/nav_manage1"
        android:icon="@drawable/ic_menu_manage"
        android:title="Tools" />

    <item android:title="App Category"></item>

    <item
        android:id="@+id/nav_gallery1"
        android:icon="@drawable/ic_menu_gallery"
        android:title="Gallery" />
    <item
        android:id="@+id/nav_slideshow2"
        android:icon="@drawable/ic_menu_slideshow"
        android:title="Slideshow" />
    <item
        android:id="@+id/nav_manage2"
        android:icon="@drawable/ic_menu_manage"
        android:title="Tools" />

</menu>

my activity_main file is

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

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="220dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        android:background="@color/colorAccent"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer"
        app:itemTextColor="@color/colorWhite"
        app:itemIconTint="@color/colorWhite"
        app:itemBackground="@drawable/drawer_item_bg"/>

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

You can achieve this by custom drawer. Try below link. Hope it will solve your problem.

Custom navigation drawer

In custom layout add imageview on top and then scrollview and inside scrollview all your layout. so logo will be fixed and items can scroll.

Or you can try this solutions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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