Understanding how actually drawRect or drawing coordinates work in Android

前端 未结 5 488
猫巷女王i
猫巷女王i 2020-12-13 13:22

I am trying to draw a rectangle over a canvas and I am facing troubles to understand the in-depth of rectangle draw of Android. I\'ve read tutorials and every possible but I

5条回答
  •  情深已故
    2020-12-13 14:07

    This will make sense.

    float left = 100, top = 100; // basically (X1, Y1)
    
    float right = left + 100; // width (distance from X1 to X2)
    float bottom = top + 100; // height (distance from Y1 to Y2)
    

    Thus

    RectF myRectum = new RectF(left, top, right, bottom);
    canvas.drawRect(myRectum, myPaint);
    

提交回复
热议问题