Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Glide: Show a blurred image before loading actual image

Tags:

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 very small size blurred image before displaying the actual image. Once the image is cached, directly full sized image should be shown.

Image Displaying flows goes like this: - If image is downloaded for the first time, first download a small scaled image, and then download full resolution image. - If image has been downloaded before, directly show full scale image.

I cannot find any method in Glide library, which tell me if a file exist in cache or not.

Any idea, how this can be done.

like image 840
Abhishek Batra Avatar asked Jun 21 '16 12:06

Abhishek Batra


People also ask

Does glide cache images Android?

Glide enables effective loading and caching of images. You can load images from a variety of sources such as files URIs, Android resources, bitmaps, drawables, etc. Just use the load() method to receive images. Image editing and more transformations.

How do you show pictures on Glide?

To simply load an image to LinearLayout, we call the with() method of Glide class and pass the context, then we call the load() method, which contains the URL of the image to be downloaded and finally we call the into() method to display the downloaded image on our ImageView.

How does Android image loading library glide and fresco work?

The image loading libraries like Glide and Fresco take care of this, they cancel all the tasks properly and only load the images which are visible to the user. These libraries are aware of the activity, and fragment lifecycle, this way they know which image downloading or bitmap decoding tasks need to be canceled.


1 Answers

Glide.with(context.getApplicationContext())
                        .load(Your Path)   //passing your url to load image.
                        .override(18, 18)  //just set override like this
                        .error(R.drawable.placeholder)
                        .listener(glide_callback)
                        .animate(R.anim.rotate_backward)
                        .centerCrop()
                        .into(image.score);
like image 168
Hiren Avatar answered Oct 05 '22 15:10

Hiren