Is it possible to play GIF format in Android? [closed]

梦想的初衷 提交于 2019-12-31 03:29:06

问题


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/



来源:https://stackoverflow.com/questions/3163706/is-it-possible-to-play-gif-format-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!