不断学习,做更好的自己!💪
| 视频号 | CSDN | 简书 |
|---|---|---|
| 欢迎打开微信,关注我的视频号:KevinDev | 点我 | 点我 |
效果图
代码
1. 布局文件
activity_coupon.xml
2. 自定义 View
首先肯定需要编写一个类,让它继承自 LinearLayout
/**
* Created on 2021/7/15 18:40
*
* @author Gong Youqiang
*/
public class CouponDisplayView extends LinearLayout {
private Paint mPaint;
private float gap = 8;
private float radius = 10;
private int circleNum;
private float remain;
public CouponDisplayView(Context context) {
this(context,null);
}
public CouponDisplayView(Context context, AttributeSet attrs) {
this(context, attrs,0);
}
public CouponDisplayView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setDither(true);
mPaint.setColor(Color.WHITE);
mPaint.setStyle(Paint.Style.FILL);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
for (int i=0;i
关注
打赏
