How to add another layout to NavigationView

I am trying to add Expandlistview to my NavigationView but it is failing. Can I add a layout below the header?

enter image description here

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

      

+3


source to share


2 answers


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



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

      

+1


source


you can use the listview on the listview of navigation boxes and add a title view to the list that contains the expandable listview. I'm not sure, but you can check it



+1


source







All Articles