我有这个代码:
public class TestView extends View {
private Path mPath;
private Paint mPaint = new Paint();
public TestView(Context context) {
this(context, null);
}
public TestView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public TestView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mPath = new Path();
mPath.moveTo(0, 0);
mPath.quadTo(50, -50, 100, 0);
mPath.quadTo(150, 50, 200, 0);
mPath.quadTo(250, -50, 300, 0);
mPath.quadTo(350, 50, 400, 0);
mPath.quadTo(450, -50, 500, 0);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.save();
canvas.translate(0, …Run Code Online (Sandbox Code Playgroud)