Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

 3 Answer(s)

  • Android doesn't support the playing of animated GIF files. If you need to play them then you need to break them apart into frames, and animate each frame one by one.

    1.Creat anim.xml file in res/drawable folder with following content:

    <item android:drawable="@drawable/image&#95;3" android:duration="250" />
    <item android:drawable="@drawable/image&#95;2" android:duration="250" />
    <item android:drawable="@drawable/image&#95;1" android:duration="250" />
    <item android:drawable="@drawable/image" android:duration="250" />
    

    2.In the layout xml file inside which you want to show the animation:

    //... //..

    3.@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

    final ImageView animImageView = (ImageView) findViewById(R.id.ivAnimation);
    animImageView.setBackgroundResource(R.drawable.anim);
    animImageView.post(new Runnable() {
        @Override
        public void run() {
            AnimationDrawable frameAnimation =
                (AnimationDrawable) animImageView.getBackground();
            frameAnimation.start();
        }
    });
    // ... other code ... 
    

    }

  • As we know that Android does not support Gif animations natively, but we can achieve it by using some libraries. You can use the "Ion" library.


    For eclipse, you can download the library. For Studio, Gradle : compile 'com.koushikdutta.ion:ion:2.+'

    Android :

    ImageView image = (ImageView)findViewById(R.id.imageGif);
    Ion.with(image).load("http://mygifimage.gif");
    



    Hope this solves your problem.

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: