使用滑行加载时,ImageSwitcher幻灯片动画不起作用

时间:2018-08-09 15:51:14

标签: android animation android-glide imageswitcher

当使用滑行加载时,ImageSwitcher幻灯片动画不起作用。

imageSwitcher.setInAnimation(In);
imageSwitcher.setOutAnimation(Out);
Glide
     .with(getActivity())
     .load(imageURL)
     .into((ImageView) imageSwitcher.getCurrentView());

当从本地资源加载图像而不会滑动时,此动画效果很好

imageSwitcher.setImageResource(data.get(position).getImage_drawable());

1 个答案:

答案 0 :(得分:0)

只需像这样使用它:

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()