import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
public class CustomViewRectF extends View {
public CustomViewRectF(Context context) {
super(context);
}
public CustomViewRectF(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
private Paint customPaint(int color) {
Paint paint = new Paint();
paint.setColor(color);//画笔颜色
paint.setStyle(Paint.Style.FILL);//实心
paint.setStrokeWidth(6);//画笔宽度
paint.setAntiAlias(true);//光滑
return paint;
}
/**
-
在纸上画矩形
-
@param canvas 纸
*/
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
/**
-
画矩形 以两个点来画,起点和终点,通常是左上为起点