毕加索在向上滚动时调整字段大小

picasso resize field on scroll up

我有这个图片视图:

   <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card_view:cardCornerRadius="0dp"
        android:id="@+id/card_view"
        android:layout_marginBottom="1dp"
        android:layout_marginEnd="0dp"
        android:layout_marginLeft="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginStart="0dp"
        android:layout_marginTop="0dp">

<ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="0dp"
        android:id="@+id/imageViewHero"
        android:adjustViewBounds="true"/>

和毕加索

Picasso.with(context).load(post.getImageUrl()).into(holder.imageView);

问题是我的 recyclerview 有很多图片,当我向下滚动时它很好,但是当我向上滚动时,一些图片会再次加载,我的 cardview 高度会再次提高,从而导致糟糕的用户体验。

有什么想法吗?我怎样才能修复我的 cardview 尺寸?

给你的 ImageView 一个固定的高度并将 scaleType 设置为 centerCrop。

我相信这应该可以解决您的问题,因为 ImageView 中的环绕内容高度可能是导致高度跳跃的原因