2012-02-07 134 views

回答

0

圖像應該由不同的可繪製視圖構建,以便您可以抓取按下的狀態。

如果您在哪裏使用靜態圖像,則無法使用座標系(基於px),因爲手機和其他Android設備沒有相同的屏幕尺寸。這種方式的其他選擇是使用dip(密度獨立像素)而不是px。

1

這可能不是做的最好的方式,但我做

double windowWidth = getWindow().getDecorView().getWidth(); 
double windowHeight = getWindow().getDecorView().getHeight(); 
float xDensity = event.getX(); 
double x = (xDensity/windowWidth) * 100; 
float yDensity = event.getY(); 
double y = (yDensity/windowHeight) * 100; 

* 100沒有必要取得了成功;我只是爲了顯示目的。