混合开发时,使用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.运行程序,使用结束;
原文:https://www.cnblogs.com/yi-snow-W/p/10916292.html