Android canvas draw rectangle

2019-01-03 12:15发布

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)

Thanks.

I try this example

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:

enter image description here

7条回答
倾城 Initia
2楼-- · 2019-01-03 13:09

Try paint.setStyle(Paint.Style.STROKE)?

查看更多
登录 后发表回答