Github image loading framework glide usage introduction,
Introduction:
Glide is a library on Android that focuses on image loading and caching.
Step 1: import a package
Open the build. gradle file in the project directory and enter the following code:
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'}
Tip: if the error "Android Studio fails to debug with error org. gradle. process. internal. ExecException" is reported, add the red box code.
Ii. Call
Single ImageView call
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);
Adapter call
@Overridepublic 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;}