Glide制作圆形图片
上效果图:
第一步:
AndroidStudio添加依赖库:
compile 'com.github.bumptech.glide:glide:3.5.2'
第二步:
<ImageView android:id="@+id/headImg" android:layout_width="60dp" android:layout_height="60dp" />
第三步:
ImageView headImage= (ImageView) findViewById(R.id.headImg);
第四步:
private void initData(){ String headerImgUrl="http://tupian.qqjay.com/tou3/2016/0829/166db6f7028c08a955bfa75974964875.jpg"; Glide.with(this) .load(headerImgUrl) .asBitmap() .centerCrop() .placeholder(R.drawable.head_img) .into(new BitmapImageViewTarget(headImage){ @Override protected void setResource(Bitmap resource) { super.setResource(resource); RoundedBitmapDrawable circularBitmapDrawable= RoundedBitmapDrawableFactory.create(getBaseContext().getResources(),resource); circularBitmapDrawable.setCircular(true); headImage.setImageDrawable(circularBitmapDrawable); } }); }
参考资料:
Glide 一个专注于平滑滚动的图片加载和缓存库