Getx (), Gety (), getrawx (), and getrawy () of motionevent

Source: Internet
Author: User
Tags gety

MotioneventGetx (), Gety (), getrawx (), getrawy ()(00:42:41)

Classification: Technology

MotioneventDifference between getx (), Gety (), getrawx (), and getrawy ()

Summary:
If you implement the ontouchlistener interface in an activity, you need to override the ontouch (view, motionevent event) method. getrawx () and getrawy () obtain the location relative to the screen, getx () and Gety () always obtain the coordinates of the touch position of the view (the two values do not exceed the length and width of the view ).

Getx is always the X position of the view you touch, and this X is the position of the mouse relative to this view;

Y is also.

Getrawx is the X position of the view you touch. This is the position relative to the screen.

If you override the ontouchevent (motionevent event) of the activity, the coordinates of the screen click position are obtained. Event. getx () and event. the value obtained by getrawx () is the same, event. gety () and event. the value obtained by getrawy () is the same, and the coordinates of the title bar can be obtained, but the coordinates of the status bar cannot be obtained. (Note: There are two sections of activity width: one is the status bar and the other is the title bar, each of which occupies 25 pixels)

 

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.