本篇Blog记录圆角ImageView的实现
先说下思路
- 获取配置属性
- 判断裁剪方式
- 绘制
下面正式开始
获取配置属性
我们现在attrs中定义相关属性
<declare-styleable name="RoundImageView">
<attr name="radius" format="dimension" />
<attr name="leftTopRadius" format="dimension" />
<attr name="rightTopRadius" format="dimension" />
<attr name="leftBottomRadius" format="dimension" />
<attr name="rightBottomRadius" format="dimension" />
</declare-styleable>
上述属性分别定义了整体圆角和四个单独的圆角
之后分别获取相关属性进行设置。