I am trying to make an hexagonal imageview with rounded corners helped by some code I found and working with arcs to draw corners. This method is not working probably because I am doing something wrong. I hope there is an easier method, too.
This is my code for the first arc-corner, but the result is not good.
private void calculatePath(float radius) {
float halfRadius = radius / 2f;
float triangleHeight = (float) (Math.sqrt(3.0) * halfRadius);
float centerX = getMeasuredWidth() / 2f;
float centerY = getMeasuredHeight() / 2f;
this.hexagonPath.reset();
this.hexagonPath.moveTo(centerX, centerY + radius);
this.hexagonPath.lineTo(centerX - triangleHeight / 4f * 3f, centerY + radius / 8f * 5f);
this.hexagonPath.arcTo(new RectF(centerX - triangleHeight, centerY + radius / 8f * 5f, centerX - triangleHeight / 4f * 3f, centerY + halfRadius / 2f), 30f, 180f);
this.hexagonPath.lineTo(centerX - triangleHeight, centerY - halfRadius);
this.hexagonPath.lineTo(centerX, centerY - radius);
this.hexagonPath.lineTo(centerX + triangleHeight, centerY - halfRadius);
this.hexagonPath.lineTo(centerX + triangleHeight, centerY + halfRadius);
this.hexagonPath.close();
invalidate();
}
This is the result where as you can see there isn't any arc:
Please help me finding a solution or an easier method.
Also please don't link me libraries, I want to do this by myself for my app.
Sorry for my English, not my main language.