Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the difference between getRawX () and getX () in Android

Shulou Source: shulou.com Published: 2022-06-02 12:04:12 10月30日 Update

This article mainly introduces what are the differences between getRawX () and getX () in Android. The article is very detailed and has certain reference value. Interested friends must finish reading it!

The difference between 1.getRawX () and getX ()

GetRawX (): absolute coordinat

GetX (): relative coordinat

MBtn_sate.setOnTouchListener (new OnTouchListener () {@ Override public boolean onTouch (View v, MotionEvent event) {if (event.getAction () = = MotionEvent.ACTION_DOWN) {Log.e ("," ACTION_DOWN= "+ v.toString () } else if (event.getAction () = = MotionEvent.ACTION_UP) {Log.e ("", "ACTION_UP=" + v.toString ()) } else if (event.getAction () = = MotionEvent.ACTION_MOVE) {/ / getRawX () X coordinate if (event.getRawX () > v.getLeft () & & event.getRawX () on the screen)

< v.getRight() && event.getRawY() >

V.getTop () & & event.getRawY ()

< v.getBottom()) { Log.e("", "超出 "); } //getX()相对于控件X坐标的距离 if(event.getX() < 0 || event.getY() < 0 || event.getX() >

(v.getRight ()-v.getLeft ()) | | event.getY () > (v.getBottom ()-v.getTop ()) {Log.e ("", "out of bounds");}} return false;}}) These are all the contents of this article entitled "what are the differences between getRawX () and getX () in Android". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Coordinates content controls articles values interests guys buddies screens more knowledge industry information channels channels references help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information Microsoft vpn MySQL