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

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

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

我知道它的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);
                    }
                });
android android-recyclerview android-glide
3个回答
0
投票

试试这个

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

0
投票

使用RecyclerView的属性,

recyclerview.setHasFixedSize(true);

0
投票

最后,我通过将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);
© www.soinside.com 2019 - 2024. All rights reserved.