android - 每个 Recyclerview 项目都显示在整个页面中
问题描述
这是我XML
的项目代码RecyclerView
。问题是,每个项目都显示在应用程序的整个页面中。请帮我解决这个问题:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rootlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:background="@color/black"
android:gravity="center">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/iv_wall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
app:riv_corner_radius="5dp" />
<View
android:id="@+id/view_wall"
android:layout_width="160dp"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:background="@drawable/bg_gradient_black_round"
android:gravity="center_vertical" />
解决方案
您已将项目的宽度和高度设置为 match_parent,这使您的项目比您想要的更大。像这样使用smth:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rootlayout"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginLeft="8dp"
android:background="@color/black"
android:gravity="center">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/iv_wall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
app:riv_corner_radius="5dp" />
<View
android:id="@+id/view_wall"
android:layout_width="160dp"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:background="@drawable/bg_gradient_black_round"
android:gravity="center_vertical" />
推荐阅读
- javascript - 函数执行后没有设置 React props
- python - 熊猫数据框中相应行之间的日期差异
- vba - VBA 增量字符间距
- r - 从 igraph 中的图中删除选定的短路径
- ios - 缺少图标 - 如何添加 Xcode appicon 模板中不可用的图标?
- linux - CLI:确认问题的退出代码?1 或 0
- javascript - 从 javascript 与正在运行的 python 通信的正确方法
- c++ - 如何在 C++ 中创建一个可以返回静态或自动存储对象而无需复制的函数?
- azure-devops - 管道中的 VS 测试失败,缺少“Microsoft.NET.Test.Sdk”
- sql - 在同一个查询中查询每日汇总,然后每月汇总?