我正在使用glide在我的android项目中加载gif。Glide.with(getActivity()).load(mainDrawable).asGif().into(mainDrawableView);
这样可以使gif重复播放,如何阻止gif循环播放?
最佳答案
这对我有用。滑翔V4
Glide.with(this).asGif().load(/*your gif url*/).listener(new RequestListener<GifDrawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GifDrawable resource, Object model, Target<GifDrawable> target, DataSource dataSource, boolean isFirstResource) {
resource.setLoopCount(1);
resource.registerAnimationCallback(new Animatable2Compat.AnimationCallback() {
@Override
public void onAnimationEnd(Drawable drawable) {
//do whatever after specified number of loops complete
}
});
return false;
}}).into(imageView);