gpt4 book ai didi

android - RecyclerView 项目超出边距范围

转载 作者:行者123 更新时间:2023-12-05 00:21:17 25 4
gpt4 key购买 nike

我有一个包含 4 个项目的 RecyclerView 和 clipToPadding设置为假

我为两个边距设置了 50dp,并且为 backgroundColor 正确执行了边距,但是 RecyclerView 的项目超出了 RecyclerView 边界。

<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:background="#0F0"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">

</android.support.v7.widget.RecyclerView>

这是演示的图像
enter image description here
.

黑色背景是父ConstraintLayout,绿色背景是设置给recyclerView的颜色,白色/蓝色项是ViewHolders。

我在这张图片中有一个自定义的 LayoutManager,但是默认的 LinearLayoutManager 也会出现这个错误。

知道可能是什么原因吗?

最佳答案

当您拥有 clipChildren 时会发生此错误。在您的父布局中设置为 true .

删除该行,它应该可以解决您的错误。

关于android - RecyclerView 项目超出边距范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51125256/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com