简介:
glide为Android上一个专注于图像加载和缓存的库。
使用步骤:
一:导包
在项目目录下,打开build.gradle文件,输入以下代码:
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.github.bumptech.glide:glide:3.6.0'
}
二:调用
单个ImageView调用
ImageView imageView = (ImageView) findViewById(R.id.iv_glide);
Glide.with(this).load("http://img2.niushe.com/upload/201304/19/14-22-45-63-26144.jpg").into(imageView);
@Override
public View getView(int position, View recycled, ViewGroup container) {
final ImageView myImageView;
if (recycled == null) {
myImageView = (ImageView) inflater.inflate(R.layout.my_image_view,
container, false);
} else {
myImageView = (ImageView) recycled;
}
String url = myUrls.get(position);
Glide.with(myFragment)
.load(url)
.centerCrop()
.placeholder(R.drawable.loading_spinner)
.crossFade()
.into(myImageView);
return myImageView;
}