나는 안드로이드를 배우고 캔버스에 다른 도형을 그리려하고있다. 순간 나는 다른 각도 타원형으로 붙어있다 : 나는 path.addRoundRect()
방법 (반경의 배열을 취하는 일)을 사용하려고했습니다안드로이드에서 도형을 그리는 법
하지만 알아낼 수있는 것을 값은 내가해야 그런 모양을 이루기 위해 그곳을 지나가십시오. 또한 path.lineTo()
을 사용해 보았지만 그런 결과를 얻을 수 없었습니다 (비슷한 종류 였지만 여전히 필요한 것은 아닙니다). 이것을 달성하기위한 좋은 해결책은 무엇입니까?
편집 1 : 내가 시도하는 것은 다음입니다 :
Path path= new Path();
path.moveTo(x - radius, y - radius/ 1.5f);
path.lineTo(x - radius/ 4, y - radius);
path.lineTo(x, y - radius);
path.lineTo(x + radius/ 2, y - radius);
path.lineTo(x + radius, y - radius/ 2);
path.lineTo(x, y + radius/ 2);
path.lineTo(x - radius/ 2, y + radius/ 1.5f);
path.lineTo(x - radius, y + radius/ 4);
path.lineTo(x - radius, y - radius/ 1.5f);
path.close();
Paint pathPaint = new Paint();
pathPaint.setColor(Color.BLACK);
pathPaint.setStrokeWidth(2.5f);
pathPaint.setDither(true);
pathPaint.setStyle(Style.STROKE);
pathPaint.setStrokeJoin(Join.ROUND);
pathPaint.setStrokeCap(Cap.ROUND);
pathPaint.setPathEffect(new CornerPathEffect(20));
pathPaint.setAntiAlias(true);
canvas.drawOval(new RectF(x - radius, y - radius+ 2, x + radius-2, y + radius- 2), pathPaint);
canvas.drawPath(path, pathPaint);
X와 Y는 디스플레이 및 반경에 대한 몇 가지 좌표는 원의 반경 (내가 원으로 그리기 시작했다). 14px와 같습니다.
float[] radii = new float[] {
5,
5,
1,
1,
5,
1,
1,
1,
};
path.addRoundRect(new RectF(x - radius, y - radius, x + radius,
y + radius),
radii, Direction.CW);
canvas.drawPath(path, pathPaint);
코드를 게시 할 수 있습니까? – petey
http://developer.android.com/reference/android/graphics/drawable/shapes/OvalShape.html –