In a layout, there is a control view v.
You can obtain its position in the layout by using the following methods:
V. getleft ();
V. getright ();
V. getbottom ();
V. gettop ();
In this way, we can obtain the position of the control's top, bottom, left, and right, relative to the parent, that is, its top, bottom, and left are several pixels away from the parent.
However, note: getleft () indicates the distance between the left side and the left side of the parent.
Note: getright () indicates the distance between the right side and the left side of the parent.
However, please note: gettop () indicates the distance between the top and the top of the parent.
Note: getbottom () indicates the distance between the lower part and the upper part of the parent.
Likewise, the same is true for parameters in the V. layout (L, t, R, B) method.
Use the following method to obtain the position of a widget on the screen:
Int v_location [] = new int [2];
V. getlocationonscreen (v_location );
Int step_ball_location_0 = v_location [0];
Int step_ball_location_1 = v_location [1];
Step_ball_location_0 and step_ball_location_1 are positions.
Note: it cannot be executed in the oncreate () method !!!! In this case, step_ball_location_0 and step_ball_location_1 are both 0.