画圆
程序员文章站
2022-03-10 12:13:30
...
package com.example.dell.day01_0830;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
/**
* Created by Dell on 2018/9/1.
*/
public class Custom extends View{
public Custom(Context context) {
super(context);
}
public Custom(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public Custom(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
canvas.drawCircle(100,100,100,paint);
}
}
“`