【问题备忘录】Android RecycleView的item之间间距过大的问题

博主分享了在使用pdfRenderer和RecyclerView时遇到的问题,发现item布局高度设置为match_parent导致间距异常。调整为wrap_content后解决了问题,关键在于理解约束布局规则。

初开发app,遇到问题,特此记录。

今天使用pdfRenderer配合recycleView制作简单的pdf阅读,但是发现item的ImageView刚开始是好的,各个item的布局紧凑。如图。

刚开始图片状态
但是滑动之后,item的间距变大。如图。

滑动之后item之间间距变大**最后发现是因为item的布局的根layout的height是match_parent;改为wrap_content就可以了。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
         />
</androidx.constraintlayout.widget.ConstraintLayout>
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值