Android 图片加载库Glide
16lz
2021-01-23
github:https://github.com/bumptech/glide
wiki:https://github.com/bumptech/glide/wiki/Configuration
jar包下载:https://github.com/bumptech/glide/releases
gradle配置:
repositories { mavenCentral() // jcenter() works as well because it pulls from Maven Central}dependencies { compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.android.support:support-v4:19.1.0' //v4包即可}
Proguard
-keep public class * implements com.bumptech.glide.module.GlideModule-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** { **[] $VALUES; public *;}
如何使用:
// For a simple view:@Override public void onCreate(Bundle savedInstanceState) { ... ImageView imageView = (ImageView) findViewById(R.id.my_image_view); Glide.with(this).load("http://goo.gl/gEgYUd").into(imageView);}// For a simple image list:@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;}
关于with方法:就是传context
关于load方法:
示例地址
更多相关文章
- android 自定义图片剪裁
- android下拉菜单spinner的使用方法
- Android第五期 - 更新自己的apk本地与网络两种方法
- Android HandlerThread使用方法
- Android——ImageButton【图片按钮】的点击事件与属性
- android 选择本地图片并预览
- android-2.2以下杀进程方法:restartPackage();
- Android 实现文件(图片)上传