小编Jas*_*ngh的帖子

回收器视图中的动态图像高度

我想使用Glide加载具有动态高度的图像。我有一个ImageView,其高度为wrap_content,宽度为match_parent。回收器视图首次加载时。第一幅图像的高度大于其余图像的高度。当我向下滚动视图进行回收时,我的较大高度的图像可以很好地加载且没有任何像素化;当我滚动回到顶部的第一张较大图像时,它得到了像素化的感觉。由于图像变得像素化。我不想在recyclerview上使用setRecyclable(false)。这是实现

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/drc_imageView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        android:src="@color/OFF_WHITE" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

用于加载图像

GlideApp
                .with(context)
                .asBitmap()
                .fitCenter()
                .load(absoluteHomeList.get(position - 1).getDynamic_card_url())
                .into(holder.dynamicImageView);
Run Code Online (Sandbox Code Playgroud)

这是供参考的图像 在第一个图像中,当未回收图像时,图像正确加载而没有像素化

在第二张图片中,我上下滚动了回收站视图,第一张图片被像素化

android android-recyclerview android-glide

0
推荐指数
1
解决办法
1402
查看次数