how can i stop the animation? If the file type must be GIF.
.load().asBitmap() will load the first frame. This is the most effective.
Otherwise check how GlideDrawableImageViewTarget starts the drawable: you can extend that class and stop it immediately after super starts it and use into(new MyStoppedGDIVT(imageView)) instead of into(imageView). You'll also need to explicitly apply a transformation (centre crop or fit center). Note that this version still loads all the GIF bytes into memory, even though only the first frame will be displayed. You may be able to display any frame by programmatically advancing the drawable.
@TWiStErRob I'll try it. Thanks!!!
If you want to start/stop on user request: load as normal (or force with asGif()) and in a click listener:
Drawable drawable = imageView.getDrawable();
if (drawable instanceof Animatable) {
Animatable gif = (Animatable)drawable;
if (gif.isRunning()) gif.stop() else gif.start();
}
Most helpful comment
If you want to start/stop on user request: load as normal (or force with
asGif()) and in a click listener: