android如何添加gif动态图片

版权声明:有需要的请联系QQ1634475153,欢迎技术交流 https://blog.csdn.net/jinmie0193/article/details/82810936

使用android-gif-drawable

GIT地址: https://github.com/koral–/android-gif-drawable

1.首先添加引用文件 ,只需要的app的build.gradle里添加

dependencies {
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
}

2.其次在对应layout文件下添加自定义gif控件,在这个控件里直接添加gif动画文件。

<pl.droidsonroids.gif.GifImageView
        android:id="@+id/gv_error"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/gif"/>

这样就可以了,非常方便,多次 点击也不会出现OOM。

当然也可以用java代码添加,详情请看git地址

猜你喜欢

转载自blog.csdn.net/jinmie0193/article/details/82810936
今日推荐