yi-snow-W

为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.运行程序,使用结束;

分类:

技术点:

相关文章:

  • 2021-12-15
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2021-12-17
  • 2021-07-16
  • 2022-02-03
猜你喜欢
  • 2021-12-19
  • 2021-11-13
  • 2021-10-27
  • 2022-01-01
  • 2022-12-23
  • 2021-10-21
相关资源
相似解决方案