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

问题描述 投票:0回答:1

我想使用Glide加载动态高度的图像。我有一个ImageView,其高度为wrap_content,宽度为match_parent。当回收者视图第一次加载时。第一张图像的高度高于其他图像的高度。当我向下滚动视图得到回收时,我的较大高度图像加载精细而没有任何像素化当我向后滚动到顶部到第一个更大的图像时它变得像素化我认为当视图被回收滑动时使用较小的回收器imageview高度用于下采样较大的高度由此得到像素化的图像。我不想在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>

用于加载图像

GlideApp
                .with(context)
                .asBitmap()
                .fitCenter()
                .load(absoluteHomeList.get(position - 1).getDynamic_card_url())
                .into(holder.dynamicImageView);

这是参考In first image when is not recycled image is loading properly without pixelating的图像

In second image i scrolled recycler view down and back to top the first image gets pixelated

android android-recyclerview android-glide
1个回答
3
投票

在使用滑行使用加载图像之前

holder.dynamicImageView.layout(0,0,0,0);
© www.soinside.com 2019 - 2024. All rights reserved.