gpt4 book ai didi

android - 在 android 中显示 gif

转载 作者:行者123 更新时间:2023-11-29 15:05:03 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com