close

抓取螢幕座標


 

 

 

右鍵->soure->override->onTouchEvent();

@Override
public boolean onTouchEvent(MotionEvent event) {
int x = (int) event.getX();//取x軸
int y = (int) event.getY();//取y軸
int action = event.getAction();//取整數
switch (action) {
case MotionEvent.ACTION_DOWN:
setTitle("按下:"+x + "," + y);
break;
case MotionEvent.ACTION_MOVE:
setTitle("平移:" + x + "," + y);
break;
case MotionEvent.ACTION_UP:
setTitle("彈起:"+x + "," + y);
break;
}

return true;// super.onTouchEvent(event);
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 小Chiu 的頭像
    小Chiu

    Cuiu's Home

    小Chiu 發表在 痞客邦 留言(0) 人氣()