Android的画布上绘制矩形画布、矩形、Android

2023-09-11 20:16:32 作者:葬心仪式

如何绘制等边框宽度= 3,并在矩形边框颜色=黑色和部分没有内容或颜色空矩形。其作用画布使用

how to draw empty rectangle with etc. borderWidth=3 and borderColor=black and part within rectangle don't have content or color. Which function in Canvas to use

void drawRect(float left, float top, float right, float bottom, Paint paint)

void drawRect(RectF rect, Paint paint)

void drawRect(Rect r, Paint paint)

感谢。

我尝试这个例子

Paint myPaint = new Paint();
myPaint.setColor(Color.rgb(0, 0, 0));
myPaint.setStrokeWidth(10);
c.drawRect(100, 100, 200, 200, myPaint);

它绘制矩形,填充黑色,但我想只是框架围绕 这样的形象:

It draws rectangle and fill it with black color but I want just "frame" around like this image:

推荐答案

尝试 paint.setStyle(Paint.Style.STROKE)