显示动画 GIF [英] Display Animated GIF

查看:43
本文介绍了显示动画 GIF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中显示动画 GIF 图像.正如我发现 Android 本身不支持动画 GIF 的艰难方式.

但是它可以使用 AnimationDrawable 来显示动画:>

开发 > 指南 > 图像和图像图形 > 可绘制概览

该示例使用在应用程序资源中保存为帧的动画,但我需要的是直接显示动画 gif.

我的计划是将动画 GIF 分解为帧,并将每个帧添加为可绘制到 AnimationDrawable.

有谁知道如何从动画 GIF 中提取帧并将它们转换为 可绘制?

解决方案

Android 实际上可以解码和显示动画 GIF,使用 android.graphics.Movie 类.

这没有太多记录,但在 SDK 参考.此外,它用于 BitmapDecode 中的 ApiDemos 示例 带有一些动画标志的示例.

I want to display animated GIF images in my aplication. As I found out the hard way Android doesn't support animated GIF natively.

However it can display animations using AnimationDrawable:

Develop > Guides > Images & Graphics > Drawables Overview

The example uses animation saved as frames in application resources but what I need is to display animated gif directly.

My plan is to break animated GIF to frames and add each frame as drawable to AnimationDrawable.

Does anyone know how to extract frames from animated GIF and convert each of them into Drawable?

解决方案

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

This is not too much documented, but is in SDK Reference. Moreover, it is used in Samples in ApiDemos in BitmapDecode example with some animated flag.

这篇关于显示动画 GIF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆