2014-02-27 28 views
1

我開發圖紙我使用event.getRawX()得到觸屏的信息化應用。我想在Android的畫布繪製區域。如何在event.getRawX()event.getX()的正確映射做到這一點?映射event.getRawX()和event.getX()

+2

到目前爲止,你已經嘗試過什麼? –

回答

1

嘗試做這樣的事情

public boolean onTouch(final View v, final MotionEvent event) { 

    int rawXCord, rawYCord; 
    final int actionIndex = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; 
    final int location[] = { 0, 0 }; 
    v.getLocationOnScreen(location); 
    rawXCord= (int) event.getX(actionIndex) + location[0]; 
    rawYCord= (int) event.getY(actionIndex) + location[1]; 

    //do ahead accordingly 

}