Public class Res extends Activity implements View.ontouchlistener {
Button btn = null;int x = 0;int y = 0;int rawx = 0;int rawy = 0;
@OverridePublic void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);Setcontentview (r.layout.main);btn = (Button) Findviewbyid (R.id.button);Btn.setontouchlistener (this);}
Public Boolean OnTouch (view view, Motionevent event) {int eventaction = Event.getaction ();switch (eventaction) {Case Motionevent.action_down:Break ;Case Motionevent.action_move:x = (int) event.getx ();y = (int) event.gety ();rawx = (int) event.getrawx ();Rawy = (int) event.getrawy ();log.d ("DEBUG", "getx=" + x + "gety=" + y + "\ n" + "getrawx=" + rawx+ "getrawy=" + Rawy + "\ n");Break ;
Case MOTIONEVENT.ACTION_UP:
Break ;}return false;}}
Summary:
GetX () is the x-coordinate of the widget relative to its upper-left corner
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 has titlebar or full screen), GetY (), Getrawy ()
The difference between getx () and GETRAWX () in Android motionevent