3

我试图在我的 NavigationView 中添加 Expandlistview 但它失败了。我可以在标题下方添加布局吗?

在此处输入图像描述

活动主布局

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

2 回答 2

1

您可以在导航抽屉列表中使用列表视图,并将标题视图附加到包含可扩展列表视图的列表中。我不确定,但你可以检查一下

于 2015-07-09T08:17:50.160 回答
1

我的解决方案是 .. 如果您使用具有特定高度的标题布局,例如 200dp .. 然后在 activity_main.xml 中包含 margin top 0f 210dp 用于可扩展的列表视图标签.. 我希望您没有使用导航视图的菜单

<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>
于 2016-03-09T12:51:10.953 回答