问题1:如何用glide来加载长图,在我的另外一个文章中有,如下:
Glide加载长图方法
问题2:如何用glide来设置圆角图片,代码如下:
RequestOptions requestOptions=RequestOptions.centerCropTransform().optionalTransform(new MyTransition(context));
Glide.with(context).applyDefaultRequestOptions(requestOptions).load(ActivityUtils.url_request + list.get(position).getContentPictures().get(0)).into(holder_one_image.paihang_image);
MyTransition.java代码如下:
public class MyTransition extends BitmapTransformation{
private static float radius = 0f;
public MyTransition(Context context) {
this(context, 4);
}public MyTransition(Context context, int dp) {
super(context);
this.radius = Resources.getSystem().getDisplayMetrics().density * dp;
}@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform,
int outWidth, int outHeight) {
return roundCrop(pool, toTransform);
}private Bitmap roundCrop(BitmapPool pool, Bitmap source) {
if (source == null)
return null;
Bitmap result = pool.get(source.getWidth(), source.getHeight(),
Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(source.getWidth(), source.getHeight(),
Bitmap.Config.ARGB_8888);
}Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP,
BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
canvas.drawRoundRect(rectF, radius, radius, paint);
return result;
}@Override
public void updateDiskCacheKey(MessageDigest messageDigest) {}
}
参考文章如下: 【Glide库的使用】https://blog.csdn.net/zhourui_1021/article/details/75089514 (这篇文章里面还有加载圆角图片的方法)
当然还有更加方便的第三方库来通过glide快速加载各种形状的图片,依赖如下:
compile 'jp.wasabeef:glide-transformations:2.0.1'
参考文章如下: https://www.cnblogs.com/qianyukun/p/6867436.html