【发布时间】:2023-03-14 06:54:02
【问题描述】:
我正在尝试在我的主要活动中实现导航抽屉以进行用户导航。但在主页中,我希望回收站视图填充我数据库中的数据。如何设计 XML 布局以同时支持回收站视图和导航抽屉。
我的 XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<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=".Activities.MainActivity"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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" />
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_menue" />
</androidx.drawerlayout.widget.DrawerLayout>
【问题讨论】:
-
可以在片段中使用
RecyclerView,在FrameLayout容器中进行片段事务 -
你能用代码举例让我理解吗?
-
您可以添加
RecyclerView,事实上您可以在DrawerLayout中添加任何您想要的视图。如果您认为将RecyclerView与Drawerlayout一起使用需要一些基础工作,那么您就大错特错了。继续添加RecyclerView标签,如果您被困在某个地方,请相应地更新您的问题 -
好的,我已经在工具栏下完成了。
标签: java android database firebase google-cloud-firestore