Android motionevent GetX () GetY () getrawx () Getrawy () and View GetTop () getLeft ()

Source: Internet
Author: User
Tags gety

GETROWX: The coordinates of the touch point relative to the screen
GetX: The coordinates of the touch point relative to the button
GetTop: The y-coordinate of the upper-left corner of the button relative to the parent view (linerlayout)
GetLeft: The x-coordinate of the upper-left corner of the button relative to the parent view (linerlayout)
GetRight (): equivalent to the following calculation: GetLeft () +getwidth ().

When you touch the button, x, Y is relative to the upper-left point of the button. And Rawx,rawy is always relative to the screen position
GetX () and gety () always get the touch position coordinates of the view (these two values do not exceed the length and width of the view)

GetX can't say it's relative to the button's coordinates. If it's btn.setontouchlistener here, it's relative to the button.
If you have inherited the GridView in this case, drag item is not relative to item's coordinates, but relative to GridView

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.