0
我正在尝试创建需要填充的自定义形状。我不能使用“arcTo”方法,只能使用moveTo,lineTo和addArc。使用Android API Level 1路径调用填充自定义形状
这里是我的代码...
bubblePaintOutline = new Paint();
bubblePaintOutline.setColor(Color.BLACK);
bubblePaintOutline.setStyle(Paint.Style.FILL_AND_STROKE);
bubblePaintOutline.setStrokeWidth(10f);
outlinePath.moveTo(bubbleRect.left, bubbleRect.top);
outlinePath.addArc(new RectF(bubbleRect.left, bubbleRect.top, bubbleRect.left + (2 * margin), bubbleRect.top + (2 * margin)), 180, 90f);
outlinePath.moveTo(bubbleRect.left+(margin),bubbleRect.top);
outlinePath.lineTo(bubbleRect.right-(margin),bubbleRect.top);
outlinePath.addArc(new RectF(bubbleRect.right-(2*margin), bubbleRect.top,bubbleRect.right,bubbleRect.top+(2*margin)),270,90f);
outlinePath.moveTo(bubbleRect.right,bubbleRect.top+margin);
outlinePath.lineTo(bubbleRect.right,bubbleRect.bottom-margin);
outlinePath.addArc(new RectF(bubbleRect.right-(2*margin), bubbleRect.bottom-(2*margin),bubbleRect.right,bubbleRect.bottom),0,90f);
outlinePath.moveTo(bubbleRect.right-margin,bubbleRect.bottom);
outlinePath.lineTo((3.0f/4.0f)*bubbleRect.width()+bubbleRect.left,bubbleRect.bottom);
outlinePath.lineTo(position.x, position.y);
outlinePath.lineTo(position.x,bubbleRect.bottom);
outlinePath.lineTo(bubbleRect.left+margin, bubbleRect.bottom);
outlinePath.addArc(new RectF(bubbleRect.left, bubbleRect.bottom-(2*margin),bubbleRect.left+(2*margin),bubbleRect.bottom),90,90f);
outlinePath.moveTo(bubbleRect.left,bubbleRect.bottom-margin);
outlinePath.lineTo(bubbleRect.left,bubbleRect.top+margin);
outlinePath.moveTo(bubbleRect.left,bubbleRect.top);
outlinePath.close();
代码成功吸引我想要的形状,并在一个小的三角形罢了,但形状的大块不填充。 (一个充满只有一部分在一排2的“lineTo”之间。
如何使用addArc,仍然充满形状?