使用Glide时,如果使用了占位符并使用交叉淡入淡出转换,它会导致占位符产生不必要的缩放效果。占位符的大小应该在layerlist drawable中设置为50dp。使用
视图持有者:
可绘制占位符:
这个问题有解决方法吗?
这是复制代码的方法:
MainActivity:https://pastebin.com/3G7BMct3 RecyclerAdapter:https://pastebin.com/eX3T4w9s Viewholder:https://pastebin.com/Yvri5XFf 占位符:https://pastebin.com/pKputgmG
crossFade()
:
https://www.youtube.com/watch?v=7FlCJDSwoAI
没有crossFade()
:
https://www.youtube.com/watch?v=vqZKZb-BKqE
Glide.with(context)
.load(itemList.get(i))
.apply(RequestOptions.fitCenterTransform())
.placeholder(R.drawable.ic_altered_placeholder)
.transition(DrawableTransitionOptions.withCrossFade())
.into(holder.imageView);
视图持有者:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:id="@+id/vh_iv_album_single_picture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
可绘制占位符:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- needs the extra spacing otherwise the drawable will be too big -->
<item android:drawable="@drawable/ic_black_album_placeholder"
android:left="51dp" android:right="51dp" android:top="51dp" android:bottom="51dp" />
</layer-list>
这个问题有解决方法吗?
这是复制代码的方法:
MainActivity:https://pastebin.com/3G7BMct3 RecyclerAdapter:https://pastebin.com/eX3T4w9s Viewholder:https://pastebin.com/Yvri5XFf 占位符:https://pastebin.com/pKputgmG
TransitionFactory
实现自己的转换,但这需要时间。另外,您可以尝试联系PR的作者,他可能知道一些有用的信息来帮助您。 - Beloo