how to draw bezier curve in android

Solutions on MaxInterview for how to draw bezier curve in android by the best coders in the world

showing results for - "how to draw bezier curve in android"
Millie
22 Aug 2018
1public class DrawView extends View {
2
3    Paint paint;
4    Path path;
5
6    public DrawView(Context context) {
7        super(context);
8        init();
9    }
10
11    public DrawView(Context context, AttributeSet attrs) {
12        super(context, attrs);
13        init();
14    }
15
16    public DrawView(Context context, AttributeSet attrs, int defStyle) {
17        super(context, attrs, defStyle);
18        init();
19    }
20
21    private void init(){
22        paint = new Paint();
23
24        paint.setStyle(Paint.Style.STROKE);
25
26    }
27
28    @Override
29    protected void onDraw(Canvas canvas) {
30        // TODO Auto-generated method stub
31        super.onDraw(canvas);
32        path = new Path();
33        paint.setColor(Color.RED);
34        paint.setStrokeWidth(3);
35        path.moveTo(34, 259);
36        path.cubicTo(68, 151, 286, 350, 336, 252);
37        canvas.drawPath(path, paint);
38
39    }