onLayout初始化裁剪信息
在EasyConstraintLayout中初始化LayoutParamsData的paths
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
for (int i = 0, size = getChildCount(); i < size; i++) {
View v = getChildAt(i);
ViewGroup.LayoutParams lp = v.getLayoutParams();
if(lp instanceof EasyLayoutParams){
EasyLayoutParams elp = (EasyLayoutParams) lp;
elp.getData().initPaths(v);
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
在LayoutParamsData中将裁剪阴影的path和裁剪子view的保存起来,新增两个属性
public class LayoutParamsData {
Path widgetPath;
Path clipPath;
boolean needClip;
boolean hasShadow;
public LayoutParamsData(Context context, AttributeSet attrs) {
…
needClip = radius > 0;
hasShadow = shadowEvaluation > 0;
}
public void initPaths(View v) {
widgetPath = new Path();
clipPath = new Path();
clipPath.addRect(widgetRect, Path.Direction.CCW);
clipPath.addRoundRect(
widgetRect,
radius,
radius,
Path.Direction.CW
);
widgetPath.addRoundRect(
widgetRect,
radius,
radius,
Path.Direction.CW
);
}
}
---------------------
最新文章
- SOAPUI使用教程-从现有的服务创建REST模拟服务
- 看JVM就推荐这本书
- AngularJS入门心得2——何为双向数据绑定
- 如何使用vs将现有的项目或者文件夹(尤其是多层目录的)添加到项目中
- js求和算法研究
- jquery easyui combobox
- CIDR
- AlertDialog.Builder setCancelable用法
- VPN错误789:L2TP连接尝试失败
- Object.assign()
- Redis学习笔记01--主从数据库配置
- Ansible安装部署及常用模块详解
- Java技巧之双括弧初始化
- NET设计模式 第二部分 结构性模式(14):结构型模式专题总结
- Mybatis学习3——动态代理
- linux修改hosts
- cnn公式推导
- Statement执行静态SQL语句
- PHP-FPM 与 Nginx 的通信机制总结
- 有关padding的二三事~~
热门文章
- 浅谈矩阵加速——以时间复杂度为O(log n)的算法实现裴波那契数列第n项及前n之和使用矩阵加速法的优化求法
- windows10安装ipython
- Java 和操作系统交互,你猜会发生什么?
- 使用git版本管理时的免密问题
- Vue基于vuex、axios拦截器实现loading效果及axios的安装配置
- 使用Kafka的一些简单介绍: 1集群 2原理 3 术语
- Mysql8- Public Key Retrieval is not allowed
- Cannot change column &#39;id&#39;: used in a foreign key constraint
- webpack之给目录起别名
- Apache Mesos 官方文档 V1.0