該文主要是講一下目前有哪些使用比較多的 圖片加載開源項目,並簡單介紹該若是使用 以及各開源項目之間有什麼區別,git
咱們該如何去選擇適合的開源項目應用到咱們的項目中?github
1、Android-Universal-Image-Loaderide
項目地址:https://github.com/nostra13/Android-Universal-Image-Loaderspa
如何使用?code
Acceptable URIs examples(可接受的Uri 例子 )blog
"http://site.com/image.png" // from Web 從網址上加載
"file:///mnt/sdcard/image.png" // from SD card 從SD 卡上加載
"file:///mnt/sdcard/video.mp4" // from SD card (video thumbnail)
"content://media/external/images/media/13" // from content provider 從內容提供者上加載
"content://media/external/video/media/13" // from content provider (video thumbnail)
"assets://image.png" // from assets //從資源文件中加載
"drawable://" + R.drawable.img // from drawables (non-9patch images)
注: 建議使用 ImageView.setImageResource(); 代替 ImageLoader
使用示例(Sample):圖片
ImageLoader imageLoader = ImageLoader.getInstance(); // Get singleton instance 獲取實例
// Load image, decode it to Bitmap and display Bitmap in ImageView (or any other view // which implements ImageAware interface)
imageLoader.displayImage(imageUri, imageView);
// Load image, decode it to Bitmap and return Bitmap to callback
imageLoader.loadImage(imageUri, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { // Do whatever you want with Bitmap
} });
// Load image, decode it to Bitmap and return Bitmap synchronously
Bitmap bmp = imageLoader.loadImageSync(imageUri);
2、picasso資源
項目地址:https://github.com/square/picassoget
使用示例:it
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
3、fresco
項目地址:https://github.com/facebook/fresco
4、glide
項目地址:https://github.com/bumptech/glide
5、ion