让gif动画动起来
【第一种方法】 --- 亲测可行
1、 在工程的build.gradle中添加
buildscript {
repositories {
mavenCentral()
}
}
allprojects {
repositories {
mavenCentral()
}
}
2、 在app下的build.gradle中添加依赖
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.1
3、布局文件中写入你要加载的gif图片即可
<pl.droidsonroids.gif.GifImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gif2" />
【第一种方法】 --- 网上查找
这种方法看着简单,推荐
1.添加Glide图片加载框架依赖
compile 'com.github.bumptech.glide:glide:3.7.0'
2.布局文件中写一个普通的Imageview
<ImageView
android:id="@+id/ivGif"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
3.代码中直接加载本地的gif图片到Imageview上即可
Glide.with(MainActivity.this).load(R.drawable.gif1) .diskCacheStrategy(DiskCacheStrategy.ALL).into(ivGif);有新的方法,欢迎讨论留言,谢谢,祝每天开心。