gpt4 book ai didi

android - 什么是带滑行的缩略图(0.5f)方法?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:26:18 24 4
gpt4 key购买 nike

什么是 .thumbnail(0.5f) 方法,这个方法中的 0.5f 是什么,为什么我们需要在下面的代码中使用它,请解释。

Glide.with(context).load(dataList.get(position).getArtworkUrl30())
.thumbnail(0.5f)
.crossFade()

.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(holder.img);

最佳答案

thumbnail(0.5f) 设置缩略图相对于原始大小的大小。 0.5f == 缩小 2 倍,或原始尺寸的 50%。缩略图用于在加载全尺寸图像之前显示预览(而不是占位符或空白区域)。

来自文档:

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:

关于android - 什么是带滑行的缩略图(0.5f)方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47203096/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com