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,仍然充滿形狀?