Android Glide: Show a blurred image before loading actual image

后端 未结 8 1098
谎友^
谎友^ 2021-02-01 06:37

I am developing an Android app which displays full screen images to the user. Images are fetched from the server. I am using Glide to show the image. But I want to display a ver

8条回答
  •  走了就别回头了
    2021-02-01 06:45

    Better you can get idea from this Library or Use this library.

    2 ways to do Blur and Original image in Android.

    1) Initially load Blur Image Server URL path and once get success bitmap caching mechanism to load Original(Large) Image Server URL path.

    Point 1 is possible, I got answer for you( Ask your server team to get Blur image or Low quality image to make blur and then load large image). APK Link

    Glide.with(mContext)
        .load(image.getMedium())
                .asBitmap()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(new SimpleTarget() {
                    @Override
                    public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
                        // Do something with bitmap here.
                        holder.thumbnail.setImageBitmap(bitmap);
                        Log.e("GalleryAdapter","Glide getMedium ");
    
                        Glide.with(mContext)
                                .load(image.getLarge())
                                .asBitmap()
                                .diskCacheStrategy(DiskCacheStrategy.ALL)
                                .into(new SimpleTarget() {
                                    @Override
                                    public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
                                        // Do something with bitmap here.
                                        holder.thumbnail.setImageBitmap(bitmap);
                                        Log.e("GalleryAdapter","Glide getLarge ");
                                    }
                                });
                    }
                });
    

    2) Fresco by Facebook is a new image library for Android. Here’s the official blog post introducing the library. It supports the streaming of progressive JPEG images over the network which can be really helpful to display large images over slow connections. One can see the image gradually improve in quality.

    Progressive JPEGs with Facebook Fresco

提交回复
热议问题