我正在使用普通 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/