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?
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 to share