如何在回收站视图中创建自定义抽屉布局?

问题描述 投票:0回答:1

我想创建一个自定义的抽屉布局并在其中包含一个回收站视图,我该怎么做,以便所有回收站视图行都显示在抽屉布局内并使之可滚动,即我想在菜单中显示整个FoodListFragment抽屉。

我的抽屉布局

<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity"
tools:openDrawer="start">


<androidx.appcompat.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/colorPrimary"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

我的回收站视图位于片段内

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
tools:context=".FoodListFragment">


    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerview"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />

android android-recyclerview drawerlayout
1个回答
0
投票

您可以在NavigationView的帮助下实现。检查以下:

© www.soinside.com 2019 - 2024. All rights reserved.