如何显示的ImageView .gif文件? [英] How to display .gif file in imageview?
问题描述
我的布局有很多imageviews的。我想告诉.gif注意动画文件中只有一个ImageView的。我试过佳日方法(添加gif图片中的Android ),但.gif文件显示的所有布局。其他意见dissappeared。
My layout have lots of imageviews. I want to show .gif animated file in just one imageview. I tried Yash method (Adding gif image in an ImageView in android) but .gif file shown all layout. Other views dissappeared.
我想告诉所有的。
你知道吗?
推荐答案
把你的.gif文件到RES /原始文件夹,在您的片段或活动,比你可以设置GIF在ImageView的如
Put your .gif file into res/raw folder, in your fragment or activity and than you can set gif in imageview like
GifAnimationDrawable GIF;
GifAnimationDrawable gif;
try {
gif = new
GifAnimationDrawable(getResources().openRawResource(R.raw.download));
gif.setOneShot(false);
} catch (NotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
ivGif.setImageDrawable(gif);
gif.setVisible(true, true);
}
您可以从 HTTPS下载类://www.dropbox。 COM / S / rlyamlkqw02n0y9 / GifAnimationDrawable.java?DL = 0 https://www.dropbox.com/s/o6gxqfhem49khf5 /GifDe$c$cr.java?dl=0
如果上述任何环节不开放,你可以找到nelow链接类
If the any above link is not open you can find the class from nelow link
希望这会节省某人的时间很多,因为我从 http://stackoverflow.com/a/11736861/3514144但我想说明它的ImageView
hope this will save someones time lot because i admire from http://stackoverflow.com/a/11736861/3514144 but i want to show it in imageview
,以及如果链接不可用,你可以从上面的链接找到类。
As well if link is unavailable you can find class from above link.
这篇关于如何显示的ImageView .gif文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!