Android view coordinates left, right, Top, Bottom

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.