我想获得中间ImageView的像素颜色。
怎么做?
这是Activity的onTouchEvent方法。
public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction();
int x = (int)event.getX();
int y = (int)event.getY();
int pixel = bim_Map.getPixel(x, y);
// How to get a pixel color of ImageView1?
switch (action) {
case MotionEvent.ACTION_UP :
break;
}
return true;
}
以下是图表。
答案 0 :(得分:-1)
将新的OnTouchListener()应用于ImageView1,例如:
ImageView imgview1 = (ImageView) findViewById(id);
imgview1.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
int pixel = imgview1.getPixel(event.getX(), event.getY());
return true;
}
});