0
如何在Canvas onTouch中製作圖片,就像按鈕一樣。只是要按,沒有別的。我可以在Canvas中插入圖片,現在我怎樣才能讓她的onTouch?有人可以給我簡單的例子嗎?不瘋辯論,因爲這可能是愚蠢的,簡單的問題如何在畫布像按鈕中製作圖片?
謝謝
如何在Canvas onTouch中製作圖片,就像按鈕一樣。只是要按,沒有別的。我可以在Canvas中插入圖片,現在我怎樣才能讓她的onTouch?有人可以給我簡單的例子嗎?不瘋辯論,因爲這可能是愚蠢的,簡單的問題如何在畫布像按鈕中製作圖片?
謝謝
public boolean handleTouch(MotionEvent event)
{
float newX = event.getX();
float newY = event.getY();
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
if (isInRect((int) newX, (int) newY))
{
refreshView();
}
//....
}
}
不能添加一個onClick或onTouch監聽到你與畫布繪製的東西。這些偵聽器只能應用於視圖。
另一種方法是將onTouchListener應用於視圖,並找到觸摸位置以查找觸摸是否位於圖片位置。
保護布爾isInRect(INT的x,int y)對 \t { \t \t返回screenR.left = screenR.left && X <= screenR.right \t \t \t \t && Y> = screenR.top && y
2012-02-24 08:42:15