Android view coordinates left, right, Top, Bottom
1. Analysis description left, right, Top, Bottom
View for this field is described below, relative to the location of the parent layout
Left position relative to parent layout
The right position relative to the parent layout.
Top left top position relative to parent layout
Relative to the bottom position of the parent layout Bottom
For the above understanding can be understood according to the two-bit coordinate system, (left,right), (Top,bottom)
2, the corresponding API calls are as follows:
View left position mview.getleft ();
View right position mview.getright ();
View Upper side position mview.gettop ();
View lower side position mview.getbottom ();
4, the legend analysis is as follows:
For the above diagram: The analysis is described as follows:
The layout relationship is as follows A (C (B))
For a coordinate system is framelayout that is Rootview, at this time the layout can be considered with the screen is equal to the size of
For C at this time his parent layout is a then the establishment of the coordinate system should be based on this, the establishment of a two-bit coordinate system, then the GetLeft is the left of C relative to the parent layout a distance, that is P1
For b at this time his parent layout of C, so the same time the establishment of the coordinate system is naturally based on this, the Call Method Geleft (), is the B to C of the left edge of the distance, that is, P2
Extrapolate, for GetTop.
Android view coordinates left, right, Top, Bottom