How to load GIF Diagram in Android
This article mainly explains "how to load GIF diagrams in Android". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to load GIF diagrams in Android.
The specific implementation code is as follows:
Glide.with (this). AsGif (). Load (R.drawable.yiba_location). Into (location_image)
The effect of running is very stuttered, I wonder if the method is not used correctly, adjust the compression mode, or stutter; adjust the cache mode, or stutter. Took a look at my gif picture, the size is still 800K, is the picture is too large, changed to a 100K gif picture, the display effect is very good, the gif picture is very smooth. So far, it is concluded that because of the Glide framework itself, the effect of playing large-size Gif pictures is not very ideal.
Scheme
Glide is no good, so you have to think of another plan and look for it on github.
The number one android-gif-drawable library, start, has 4.8K. This should be good. Try it.
Android-gif-drawable: https://github.com/koral--/android-gif-drawable
Reference:
Compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.7'
Directly replace ImageView in the layout file with GifImageView
Run to see, it is really good ah, play very smoothly, resolutely adopt this scheme.
Explore other attributes:
GifImageView gifImageView = (GifImageView) findViewById (R.id.gifImageView) GifDrawable gifDrawable = (GifDrawable) gifImageView.getDrawable ()
Get the GifDrawable object through the GifImageView object.
GifDrawable.start (); / / start playing gifDrawable.stop (); / / stop playing gifDrawable.reset (); / / reset to restart playing gifDrawable.isRunning (); / / whether gifDrawable.setLoopCount is being played (2); / / set the number of times to play, and then automatically stop gifDrawable.getCurrentLoop () / / get the number of times gifDrawable.getCurrentPosition is being played; / / get the time between now and the start of playback gifDrawable.getDuration () / / get the time needed for a playback. Thank you for reading. The above is the content of "how to load GIF diagrams in Android". After the study of this article, I believe you have a deeper understanding of how to load GIF diagrams in Android, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!