3

NavigationView 内に Expandlistview を追加しようとしていますが、失敗します。ヘッダーの下にレイアウトを追加できますか?

ここに画像の説明を入力

activity_main レイアウト

<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

私の解決策は..特定の高さのヘッダーレイアウトを使用している場合、ex 200dp ..次に、 activity_main.xml に、展開可能なリストビュータグのマージントップ 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 に答える