2014-02-20 29 views
0

我想獲得一些關於如何執行類似於繪製windows應用程序的畫筆的提示。如果用戶觸摸那些我想繪製的可觸摸區域,就像使用不同顏色的畫筆一樣繪製(如何在android上繪圖?)。我應該使用哪個widget?imageview?)在可觸摸區域進行Android繪製

這裏有一些圖片可以幫助。

之前,觸摸:

Before Touching

觸摸後:

After Touching

我不是在尋找整個解決方案,我找了一些提示,也許一些片段。 非常感謝提前;)

編輯: 高級提問:我也想衡量有多好,信上面的感人,如果還不夠好,我想知道,也許這樣做可點擊區域,而不是可觸摸地區,並計算哪一個和百分比?謝謝

回答

1
One way is use get the color where user touched and compare that with the touchable area here (gray) in your case. If the pixel color is gray means user is touching at right spot if white that means untouchable area 

You can get the pixel color like this- 

imageView.setOnTouchListener(new OnTouchListener(){ 
     @Override 
     public boolean onTouch(View v, MotionEvent event){ 
     int x = (int)event.getX(); 
     int y = (int)event.getY(); 
     int pixel = bitmap.getPixel(x,y); 

     //then do what you want with the pixel data, e.g 
     int redValue = Color.red(pixel); 
     int blueValue = Color.blue(pixel); 
     int greenValue = Color.green(pixel);   
     return false; 
     } 
    }); 


Hope this helps 
+0

這將有助於!我怎麼畫黃色的東西呢?謝謝 。 – TiagoM

+1

http://stackoverflow.com/a/16650524/472336這可能會幫助您繪圖 – Pramod