我正在尝试使用在画布上绘制三角形,drawPath()
但在填充三角形时遇到问题。如果我将油漆设置为,则以下代码将绘制一个三角形,STROKE
但当它设置为时,FILL
它不会绘制任何东西。我在这里做错了什么吗?
labelArrowBox.reset();
labelArrowBox.moveTo(labelPosition.x, labelPosition.y);
float x = labelPosition.x + LABEL_BOX_ARROW_WIDTH / 2;
float y = labelPosition.y - LABEL_BOX_ARROW_HEIGHT;
labelArrowBox.lineTo(x, y);
labelArrowBox.moveTo(x, y);
x = labelPosition.x - LABEL_BOX_ARROW_WIDTH / 2;
labelArrowBox.lineTo(x, y);
labelArrowBox.moveTo(x, y);
labelArrowBox.lineTo(labelPosition.x, labelPosition.y);
labelArrowBox.moveTo(labelPosition.x, labelPosition.y);
labelArrowBox.close();
Paint arrowBorderPaint = new Paint();
arrowBorderPaint.setAntiAlias(true);
arrowBorderPaint.setDither(true);
arrowBorderPaint.setColor(getContext().getResources().getColor(R.color.leaf_thin_ring));
arrowBorderPaint.setStyle(Paint.Style.FILL);
canvas.drawPath(labelArrowBox, arrowBorderPaint);