首先,导入依赖:
implementation 'com.facebook.fresco:animated-gif:1.11.0' //gif依赖
然后就可以直接在布局中使用了,
<pl.droidsonroids.gif.GifImageView
android:id="@+id/main_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@mipmap/main_share_bg" />
这个使用非常方便,是跟咱们平时使用的ImageView是一样的,从GifImageView的源码中我们不难看出,GifImageView是继承与ImageView的,是ImageView的子类,所以是比较简单方便的