使用Android API 1级路径调用填充自定义形状

使用Android API 1级路径调用填充自定义形状,android,canvas,graphics,path,Android,Canvas,Graphics,Path,我正在尝试创建一个需要填充的自定义形状。我不能使用“arcTo”方法,只能使用moveTo、lineTo和addArc 这是我的密码 bubblePaintOutline = new Paint(); bubblePaintOutline.setColor(Color.BLACK); bubblePaintOutline.setStyle(Paint.Style.FILL_AND_STROKE); b

我正在尝试创建一个需要填充的自定义形状。我不能使用“arcTo”方法,只能使用moveTo、lineTo和addArc

这是我的密码

            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并仍然填充形状?

在调用moveTo()关闭上一节之前,先添加对outlinePath.close()的调用