如何在 recyclerview 中禁用图像重新加载

How to disable image reloading in recyclerview

在我的 recyclerview 中,如果我滚动 up/down 图像会再次重新加载。它破坏了用户体验。

我知道 recyclerview 的默认行为。但我想像 Whatsapp 一样实现。如果已经加载,它们不会重新加载图像。有没有人给我推荐一下。

我的Glide库代码:

   BitmapTypeRequest glideRequestmgr = Glide.with(context).load(getGlideURL(path, context)).asBitmap();

        glideRequestmgr.diskCacheStrategy(DiskCacheStrategy.ALL)
                .dontTransform()
                .dontAnimate()
                .into(new SimpleTarget<Bitmap>() {

                    @Override
                    public void onResourceReady(Bitmap arg0, GlideAnimation<? super Bitmap> arg1) {
                        imageView.setImageBitmap(arg0);
                    }
                });

试试这个

GlideApp.with(context)
                    .asBitmap()
                    .load(pathToLoad)
                    .error(R.drawable.ob_glide_app_img_loader)
                    .listener(requestListener)
                    .into(simpleTarget)

使用 RecyclerView 的 属性,

recyclerview.setHasFixedSize(true);

最后我通过将 recyclerview 放在 NestedScrollView 中解决了这个问题

第 1 步:

<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>

第 2 步:

recyclerView.setNestedScrollingEnabled(false);