为app添加动态gif背景

混合开发时,使用H5+JS开发的动画,会让webview频繁重绘,造成资源浪费;

这时可以吧H5动画转换成gif,然后设置为背景;

小编推荐一个gif库:

githu:https://github.com/koral--/android-gif-drawable

使用方法:

添加依赖:

1.app的buid.gradle添加依赖:

dependencies {
。。。。
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'
  。。。
}
工程build.gradle添加依赖:
repositories {
mavenCentral()
。。。。

}
allprojects {
repositories {
mavenCentral()
  。。。。。

}
}

2 使用:
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/xiahuabg"
android:clickable="false"
/>
3.运行程序,使用结束;

posted on 2019-05-24 09:54  蜗牛起飞吧  阅读(461)  评论(0编辑  收藏  举报

导航