android - 在 android 中显示 gif

标签 android android-imageview

我正在使用普通 ImageView 来显示来 self 的服务器的图像,现在我想显示 gif 动画但不知道该怎么做,你能帮我吗?

最佳答案

我在我的项目中使用这个库 https://github.com/koral--/android-gif-drawable
它在 RecyclerView 中完美运行。

使用库很简单,添加即可

 compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.16'

到你的 build.gradle 文件 并像这样在你的布局中使用它

<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/src_anim"
android:background="@drawable/bg_anim"
/>

或者您可以像这样在代码中使用它:

GifDrawable gifFromPath = new GifDrawable( "/path/anim.gif" );

关于android - 在 android 中显示 gif,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38226956/

相关文章:

Android如何在ImageView上应用蒙版?

android - 如何在 Android 中翻转 ImageView?

android - 如何检测蓝牙是否连接?

android - 如何以编程方式设置 Android 设备日期/时间

android - 如何在 API 级别 8+ 中支持 searchItem.setOnActionExpandListener?

Android:EditText 隐藏在键盘后面

java - 我怎样才能指定这个 ImageView 必须显示得更小?

android - 连接在请求完成之前关闭 - Android ION

Android ListView 滚动延迟由于 ImageView 绘制

php - 如何区分 HTTP 请求与 PHP 中的 Web 浏览器或移动设备(应用程序)?