自定义View,重写onDraw()
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(Color.parseColor("#ff99cc"));
paint.setStrokeWidth(5);
Path path = new Path();
//nose
path.addOval(200,200,300,350, Path.Direction.CW);
//
path.addOval(215,260,235,280, Path.Direction.CW);
path.addOval(265,270,285,290, Path.Direction.CW);
path.moveTo(250,350);
path.cubicTo(250,350,280,380,320,380);
//face
path.moveTo(250,200);
path.cubicTo(250,200,550,200,560,380);
path.cubicTo(560,380,560,500,450,510);
path.cubicTo(450,510,280,520,320,380);
//eyes
path.addCircle(350,260,25, Path.Direction.CW);
path.addCircle(420,285,25, Path.Direction.CW);
//ear
path.moveTo(420,230);
path.cubicTo(400,140,460,130,440,230);
path.moveTo(470,260);
path.cubicTo(450,140,520,130,490,260);
//mouth
path.moveTo(330,410);
path.cubicTo(340,450,400,460,430,420);
canvas.drawPath(path,paint);
Paint fillPaint = new Paint();
fillPaint.setStyle(Paint.Style.FILL);
canvas.drawCircle(345,255,7,fillPaint);
canvas.drawCircle(415,280,7,fillPaint);
}