what is .thumbnail(0.5f) method and what is 0.5f in this method and why we need to use it in below code please explain.
Glide.with(context).load(dataList.get(position).getArtworkUrl30())
.thumbnail(0.5f)
.crossFade()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(holder.img);
thumbnail(0.5f) sets the size of thumbnail relative to original size. 0.5f == 2 times smaller, or 50% of original size. Thumbnail is used to show preview (instead of placeholder or empty space) before fullsize image is loaded.
From documentation:
This method is particularly useful in combinations of ListView and detail views. If you already display the image in the ListView, let's just say, in 250x250 pixels, the image will need a much bigger resolution in the detail view. However, from the user perspective, he already saw a small version of the image, why is there a placeholder for a few seconds until the same image gets displayed again (in a higher resolution)?
In this case, it makes a lot more sense to continue to display the 250x250 pixel version in the detail view and in the background load the full resolution. Glide makes this possible with the .thumbnail() method. In this case, the parameter is a float as the size multiplier:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With