koral--/android-gif-drawable

Gif stops playing

Closed this issue · 1 comments

I am trying to programatically draw the gif in my class file. Here is the code

GifDrawable gifFromResource;
            try {
                gifFromResource = new GifDrawable( getResources(), R.drawable.gif_anim );
                gifFromResource.setBounds(0, 0, gifFromResource.getIntrinsicWidth()+15, gifFromResource.getIntrinsicHeight()+15);
                gifFromResource.draw(canvas);
            } catch (IOException e) {
                e.printStackTrace();
            }

Now, the gif is not playing, but plays for a split second when I jump from fragments. What is the issue here, please help me.

Thanks

You need to invalidate your view on each frame to achieve animation. Look for example here: https://github.com/koral--/android-gif-drawable/blob/master/sample/src/main/java/pl/droidsonroids/gif/sample/ImageSpanFragment.kt