如何在 NavigationView 中添加其他布局
How to add other layout within NavigationView
我试图在我的 NavigationView 中添加 Expandlistview,但它失败了。
我可以在 header 下面添加布局吗?
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>
您可以在导航抽屉列表中使用列表视图,并将 header 视图附加到包含可扩展列表视图的列表。我不确定,但你可以检查一下
我的解决方案是..如果您使用具有特定高度的页眉布局,例如 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>
我试图在我的 NavigationView 中添加 Expandlistview,但它失败了。 我可以在 header 下面添加布局吗?
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>
您可以在导航抽屉列表中使用列表视图,并将 header 视图附加到包含可扩展列表视图的列表。我不确定,但你可以检查一下
我的解决方案是..如果您使用具有特定高度的页眉布局,例如 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>