使用滑行加载时,ImageSwitcher幻灯片动画不起作用。
imageSwitcher.setInAnimation(In);
imageSwitcher.setOutAnimation(Out);
Glide
.with(getActivity())
.load(imageURL)
.into((ImageView) imageSwitcher.getCurrentView());
当从本地资源加载图像而不滑动时,此动画工作正常
imageSwitcher.setImageResource(data.get(position).getImage_drawable());
就这样用它:
Glide.with(view.context)
.asDrawable()
.load(url)
.listener(object : RequestListener<Drawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
isFirstResource: Boolean
) = false
override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
isFirstResource: Boolean
): Boolean {
(view.nextView as? ImageView)?.setImageDrawable(resource)
view.showNext()
return true
}
})
.submit()