Android


How to display an animated image in the android

Coding Issue for android php java html-css and javascript

Normally android image view shows only a simple image like JPG, PNG, JPEG format, but sometimes we need to show an animated image in the Android activity. The animated image helps the user to easily understand.

So, when we need to show an animated (GIF) image in the android activity we’ll need another application for that. I would like to present 3 solutions to resolve this problem. Each way has own advantages and disadvantages.

  • android.graphics.Movie
  • WebView
  • ImageView

Using android.graphics.Movie

Android actually can decode and display animated GIFs, using android.graphics.Movie class.

WebView

This solution maybe easiest to way to display an animated image in the android. Webview cannot load Gif from the Drawable resource, It can only load from URL on the Internet or from Assets.

ImageView

We can not directly use Image view to display GIF. I am going to show you the easiest way to do this by a library:

Also read this also:

Replace the whole word with Word Boundaries in Java

There are no given tools to show an animated image on the activity. But we can show an animated image in the Android by adding a dependency in the grade file. After using this dependency we can add a view for GIF image like Image view.

Required dependence is:

Required repositories is:

After adding these dependence and repositories to your gradle file you can use in your activity. Now create your XML layout:

activity_main:

Mainactivity:

Mainifest:

String:

Gradle:

Published by Amit Pandey

Professional Android app Developer, Full Stack Web Developer, Blogger, Entrepreneur And Founder of Coding Issue. I am always trying to learn new things or new possible ways to do things.

Did you find this page helpful?

X

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

*