Display Animated GIF

后端 未结 30 2041
无人及你
无人及你 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:56

    i found a very easy way, with a nice and simple working example here

    display animated widget

    Before getting it working there are some chages to do do in the code

    IN THE FOLLOWING

        @Override
        public void onCreate(Bundle savedInstanceState){    
            super.onCreate(savedInstanceStated);   
            setContentView(new MYGIFView());
        }    
    }
    

    just replace

    setContentView(new MYGIFView());
    

    in

    setContentView(new MYGIFView(this));
    

    AND IN

    public GIFView(Context context) {
        super(context);
    

    Provide your own gif animation file

        is = context.getResources().openRawResource(R.drawable.earth);
        movie = Movie.decodeStream(is);
    }
    

    REPLACE THE FIRST LINE IN

    public MYGIFView(Context context) {
    

    according to the name of the class...

    after done this little changes it should work as for me...

    hope this help

提交回复
热议问题