Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report