希望我下面的笔记能帮助你理解相对论属于矩形、画布和视图。
/**
* Rect holds four integer coordinates for a rectangle.
* The rectangle is represented by the coordinates of its 4 edges (left, top, right bottom).
* These fields can be accessed directly. Use width() and height() to retrieve the rectangle's width and height.
*
* Note that the right and bottom coordinates are exclusive.
* This means a Rect being drawn untransformed onto a Canvas will draw into the column and row described by its left and top coordinates
* , but not those of its bottom and right.
*
* With regard to calling to Canvas#drawRect(left,top,right,bottom,paint)
*
* left: Distance of the left side of rectangle from left side of canvas.
* top: Distance of top side of rectangle from the top side of canvas
* right: Distance of the right side of rectangle from left side of canvas.
* bottom: Distance of the bottom side of rectangle from top side of canvas.
* __________________________________
*|
*|
*| __l_______________________r__
*| | view group A |
*| t| 0______________________w |
*| | | **** view group B *** | |
*| | | **** canvas of B **** | |
*| | | ********************* | |
*| | | ********************* | |
*| | | ********************* | |
*| | | ***** __________ **** | |
*| | | *****|## rect ##|**** | |
*| | | *****|##########|**** | |
*| | | *****|##########|**** | |
*| | | *****|##########|**** | |
*| | | *****|##########|**** | |
*| | | ***** ---------- **** | |
*| | | ********************* | |
*| b| h----------------------- |
*| | |
*| | |
*| -----------------------------
*|
* -----------------------------------
*
* 1. l, t, r, b are coordinates of view group B (PastryChart) relative to view group A (parent of PastryChart).
* 2. The size of canvas of B is same as the size of the view group B
* , which means canvas of B is a canvas which the view group B is rendered to.
* 3. The coordinates of rect is relative to a canvas, here is the canvas of B
* , which means the coordinates of rect going to represent child of view group B are relative to the canvas of B.
* ex. for a rect holding left = 0, the position of its left is located on the same position of the left of view group B
* ex. for a rect holding right = w, the position of its right is located on the same position of the right of view group B
* ex. for a rect holding top = 0, the position of its top is located on the same position of the top of view group B
* ex. for a rect holding bottom = h, the position of its bottom is located on the same position of the bottom of view group B
* 4. The rect is used to stored the child measurement computed in measure pass
* for forward positioning child view (PastryView) in the layout pass taken by parent view (PastryChart).
* 5. All of them are in pixels (px)
*/