The returned Rect contains 4 values:
- lower
- to the left
- to the right
- upper
bottom indicates the y coordinate of the bottom of the rectangle. left indicates the x coordinate of the left side of the rectangle. and etc.
Parent coordinate means that the values of the rectangle fall into the parent coordinate system.
Imagine that you are standing in an open field at night, looking at the moon. Your position on earth can be expressed in many ways.
If we expressed your position in your local coordinate system, you would be located at (latitude / longitude) (0, 0). When you go around the neighborhood, your local coordinate system never changes; you are always at the center (0,0) in your local coordinate system.
However, if we expressed your location using the Earth's coordinate system, you may be in (latitude, longitude) (16, 135).
You are standing on the earth, therefore the earth is your parental coordinate system.
In the same way, a view can be contained in LinearLayout. LinearLayout will be the parent of the View, so the values from getHitRect () will be expressed in the LinearLayout coordinate system.
EDIT
In general terms, a hit rectangle is a term used to define a rectangular area used to detect collisions. From an Android perspective, a hit rectangle is just an instance of the Rect type.
getLeft() methods, etc. are just data accessories in Rect, so Rect members define the same rectangle you would get by calling methods.
A typical usage scenario for Rect will handle tap events:
You can also see if two rectangles intersect with each other.
if(myRect.contains(myRect2)){
To represent a rectangle with a delete is not used directly, you can see the source . The upper, lower, left and right values use tons in the view, but the getHitRect () method is much more convenient to pass these parameters (top / bottom / left / right) to people who need them in a neat package.