Glide是一个Android上的图片加载和缓存库,其目的是实现平滑的图片列表滚动效果。
示例代码:
//Forasimpleview:@OverridepublicvoidonCreate(BundlesavedInstanceState){...ImageViewimageView=(ImageView)findViewById(R.id.my_image_view);Glide.with(this).load("https://goo.gl/h8qOq7").into(imageView);}//Foralist:@OverridepublicViewgetView(intposition,Viewrecycled,ViewGroupcontainer){finalImageViewmyImageView;if(recycled==null){myImageView=(ImageView)inflater.inflate(R.layout.my_image_view,container,false);}else{myImageView=(ImageView)recycled;}Stringurl=myUrls.get(position);Glide.with(myFragment).load(url).centerCrop().placeholder(R.drawable.loading_spinner).crossFade().into(myImageView);returnmyImageView;}
评论