问题描述
我必须在RecyclerView中使用GIF图像。在第一个位置,GIF正在播放。然后我移动到下一个项目。那么上一个GIF图片将停止。如何解决此任务。
解决方法
使用getDrawable()
方法获取GifDrawable
对象并调用stop()
方法:
((GifDrawable)buttonGifImage.getDrawable()).stop()
或者由于您已设置为背景资源:
buttonGifImage.setBackgroundResource(R.drawable.gifImage);
使用:((GifDrawable)buttonGifImage.getBackground()).stop()