Is it possible to play GIF format in Android? [clo

2020-04-18 05:59发布

问题:

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 8 years ago.

I want to add play gif format to my android app. Could this be done, and how would I do it?

回答1:

It seems that playing animated GIFs is not supported directly in Android. The Google docs state the GIF is a discouraged file type for using in your Android projects.

There are some possibilities but they all seem to require a great deal of work to show your animated GIFs.
The one thing that seems to be working is splitting up the GIF into its frame and do the animation between the frames yourself, see this question for a little bit more information. There is also this question that shows another way but the answer may be outdated because of the changes made in the cupcake release that are mentioned in the other questsion.



回答2:

You should see the API demo example for using .gif file in Your application i put the link http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapDecode.html



回答3:

Animated GIFs are supported since Android Froyo (2.2).

Earlier versions does not support animated GIFS out of the box. You can take a look at the Android Issue 3422 for more details.



回答4:

You can extract the frames from the GIF and then use a frame-by-frame animation to animate these frames in android.

For more information on the frame-by-frame animation you can take a look at the tutorial provided at http://www.app-solut.com/blog/2011/05/playing-animations-in-android/