3

I'm trying to add Expandlistview within my NavigationView but it fails. Can I add layout below header?

enter image description here

activity_main layout

<android.support.v4.widget.DrawerLayout
  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:fitsSystemWindows="true">  

<android.support.design.widget.NavigationView
    android:id="@+id/navigation"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:headerLayout="@layout/header">

    <ExpandableListView
        android:id="@+id/expanded_menu"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Telember
  • 455
  • 6
  • 24

2 Answers2

1

you can use listview in navigation drawer list and append header view to the list which contains expandable listview. I am not sure but you can check it

Ram Mandal
  • 1,899
  • 1
  • 20
  • 35
1

My solution would be .. if you are using header layout with specific height, for ex 200dp.. then in activity_main.xml include margin top 0f 210dp for expandable listview tag.. I hope you are not using menu for navigation view

<android.support.v4.widget.DrawerLayout
  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:fitsSystemWindows="true">  

<android.support.design.widget.NavigationView
    android:id="@+id/navigation"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:headerLayout="@layout/header">

<ExpandableListView
    android:id="@+id/expanded_menu"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginTop="210dp" />
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
Amit Tumkur
  • 2,752
  • 26
  • 27