android - 如何在 ScrollView 上重叠 RecyclerView
问题描述
正如我下面的代码,我试图将 Recyclerview 重叠在 ScrollView 上。我看到很少有 java 使用的教程,但我想用 xml 代码创建。我不确定我是否做得对。附件是我想创建的,请作为您的参考。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#759AF8">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="50dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Trend"
android:textStyle="bold"
android:textSize="24sp"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What's trending in Korea"
android:textSize="18sp"
android:layout_gravity="center" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/recipe_background"
android:layout_marginTop="200dp"
android:padding="20dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:elevation="7dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:orientation="vertical" />
</ScrollView>
</RelativeLayout>
解决方案
推荐阅读
- sql - 在 SQL Developer 查询中每滚动 12 小时标记 2 个实际读数与基准读数
- linux - macOS 中的 cp 命令无法识别“-t”标志
- npm - GitHub Actions Upload Artifact 未从 npm run build 中找到提供的路径
- azure-devops - 如何将 Azure SQL 数据库从一个备份到另一个?
- reactjs - 在 Safari 移动版中,当焦点更改时,表单会意外重置
- laravel - Laravel 来自模型或控制器的多维独特记录,无需 foreach
- javascript - Firebase ref.on('value') 连续调用,即使没有变化
- pandas - Pandas - 如果有零则获取最大行值,如果没有零则获取平均值
- java - 工作中延迟初始化时出错 数据库
- firebase - 仅服务器上的 Firestore 更新