Android RecyclerView头布局 Glide加载圆形头像 GreenDao创建
来源:互联网 发布:苹果6s怎么开4g网络 编辑:程序博客网 时间:2024/06/05 04:17
一、自定义圆形图片:
注意:Glide 依赖版本为4.0.0
Acticity:
Glide.with(this.getApplicationContext())
.load(iconurl)
.apply(new RequestOptions()
.centerCrop()
.priority(Priority.HIGH)
.error(R.mipmap.ic_launcher_round)
.placeholder(R.mipmap.ic_launcher)
.transform(new Formation()))
.into(homeLeft_image);
Class:
新建一个类:
public class Formation extends BitmapTransformation {
@Override
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
if (toTransform == null) {
return null;
}
int width = toTransform.getWidth();
int height = toTransform.getHeight();
int min = Math.min(width, height);
int x = (width - min) / 2;
int y = (height - min) / 2;
Bitmap bitmap = Bitmap.createBitmap(min, min, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Bitmap bitmap1 = Bitmap.createBitmap(toTransform, x, y, min, min);
Paint paint = new Paint();
paint.setShader(new BitmapShader(bitmap1, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
int r = min / 2;
canvas.drawCircle(r, r, r, paint);
return bitmap;
}
@Override
public void updateDiskCacheKey(MessageDigest messageDigest) {
}
}
二、
Recyclerview头布局:
注意:先设置好适配器再添加头布局,不然报错。
1.添加recyclerviewheader依赖
2.attachTo(recy)
三、
GreenDao创建:
public class DaoMannger { private static DaoMannger daoMannger; private DaoMaster.DevOpenHelper helper; private final String DB_NAME="shoping"; private DaoMannger(Context context){ helper=new DaoMaster.DevOpenHelper(context,DB_NAME); } public static synchronized DaoMannger getIntance(Context context){ if (daoMannger==null) daoMannger=new DaoMannger(context); return daoMannger; } public DaoBeanDao getDao(){ DaoMaster daoMaster = new DaoMaster(helper.getWritableDatabase()); DaoSession daoSession = daoMaster.newSession(); DaoBeanDao daoBeanDao = daoSession.getDaoBeanDao(); return daoBeanDao; }}
- Android RecyclerView头布局 Glide加载圆形头像 GreenDao创建
- Glide 加载圆形头像方法
- Glide 加载圆形头像方法
- Android利用glide加载圆形图片,头像的实现
- android 解决在列表条目中刷新或者加载 Glide 圆形头像会闪烁,位置错乱
- android圆形头像:相机相册加载图片到圆形头像
- Glide 圆形头像的使用
- Android 使用DisplayImageOptions加载头像 自定义圆形头像
- Glide加载圆形图片
- Glide加载圆形图片
- Glide加载圆形图片
- Glide 圆形加载图片
- RecyclerView刷新布局时Glide加载图片闪现
- imageView创建圆形头像
- Android Glide加载圆形图片,设置白色边框
- 在RecyclerView中使用Glide和CircleImageView加载圆形图片时出现图片错乱
- Android 自定义圆形旋转进度条,仿微博头像加载效果
- Android 圆形头像显示
- 如何理解 (*(void (*)())0)();
- Android中异步任务请求网络数据
- MySQL必知必会读书笔记--分析
- 浏览器兼容性问题解决方案 · 总结
- java KSoap调用WCF服务
- Android RecyclerView头布局 Glide加载圆形头像 GreenDao创建
- UVA 232
- 关于vue点击控制单个样式
- 在TensorFlow中实现文本分类的CNN
- Javascript异步理解
- 大小端问题
- Ngnix+node.js+express+socket.io 配置websocket 集群
- UVA 1368
- Linux内核