包括Android项目为.gif [英] Including a .gif in android project
本文介绍了包括Android项目为.gif的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是我怎么可以附加一个小的GIF,火我在我的game.If飞船的我的屁股,你有什么想法,我喜欢它们加热。 谢谢!
my question is how can I attach a little gif with fire to my bottom of my spaceship in my game.If you have any ideas,i'd love to heat them. Thank you!
推荐答案
我会强烈建议您使用一种新的壁画库(由Facebook的制作)。它可以处理各种图像加载的,它的高度可定制的。
I would highly recommend you to use a new Fresco library (made by Facebook). It handles all kinds of image loading and it's highly customizable.
- 最快玩GIF(比离子更快)
- 易于使用
包含这个依赖到你的build.gradle:
Include this dependency into your build.gradle:
dependencies {
// your app's other dependencies
compile 'com.facebook.fresco:fresco:0.7.0+'
}
下面是如何设置壁画链接: http://frescolib.org/docs/getting-started.html#
Here's a link how to setup Fresco: http://frescolib.org/docs/getting-started.html#
要播放GIF,你应该做的事情是这样的:
To play gif you should do something like this:
SimpleDraweeView draweeView = (SimpleDraweeView) findViewById(R.id.gif_draweeview);
Uri uri = Uri.parse("res:///" + R.drawable.gif_animation);
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(uri)
.setControllerListener(new ControllerListener<ImageInfo>() {
@Override
public void onSubmit(String s, Object o) {
}
@Override
public void onFinalImageSet(String s, ImageInfo imageInfo, final Animatable animatable) {
if(animatable != null) {
animatable.start();
}
}
@Override
public void onIntermediateImageSet(String s, ImageInfo imageInfo) {
}
@Override
public void onIntermediateImageFailed(String s, Throwable throwable) {
}
@Override
public void onFailure(String s, Throwable throwable) {
}
@Override
public void onRelease(String s) {
}
})
.build();
draweeView.setController(controller);
这篇关于包括Android项目为.gif的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文