Display Animated GIF

后端 未结 30 2082
无人及你
无人及你 2020-11-22 02:11

I want to display animated GIF images in my aplication. As I found out the hard way Android doesn\'t support animated GIF natively.

However it can display animations

30条回答
  •  醉酒成梦
    2020-11-22 02:54

    Glide 4.6

    1. To Load gif

    GlideApp.with(context)
                .load(R.raw.gif) // or url
                .into(imageview);
    

    2. To get the file object

    GlideApp.with(context)
                    .asGif()
                    .load(R.raw.gif) //or url
                    .into(new SimpleTarget() {
                        @Override
                        public void onResourceReady(@NonNull GifDrawable resource, @Nullable Transition transition) {
    
                            resource.start();
                          //resource.setLoopCount(1);
                            imageView.setImageDrawable(resource);
                        }
                    });
    

提交回复
热议问题