Motionevent getx (), GetY () and Getrawx (), Getrawy () difference

Source: Internet
Author: User
Tags gety

GetX () is the x-coordinate of the widget relative to its upper-left corner, and Getrawx () is the x-coordinate value relative to the upper-left corner of the screen (note: The upper-left corner of the screen is the upper-left corner of the phone screen, regardless of whether the activity is titlebar or full screen ), GetY (), Getrawy () If you implement a Ontouchlistener interface in one of your activity, you need to override

OnTouch(View view,motionevent event)  

This method,
GETRAWX () and Getrawy () get the position relative to the screen, GetX () and gety () are always the touch position coordinates of the view
(These two values do not exceed the length and width of the view).

If you override the activity's

Ontouchevent(motionevent event) 

, this time you get the coordinates of the screen click position. Event.getx () Gets the same value as EVENT.GETRAWX (), and Event.gety () is the same as the value obtained by Event.getrawy (), but also gets the coordinate position when the title bar is touched, but the coordinate position when the status bar is touched is not available.
( Note: The activity has two segments width: one is the status bar, one is the title bar, each width is 25 pixels)

Motionevent getx (), GetY () and Getrawx (), Getrawy () difference

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.