我使用了这个方法:
croppedBitmap =Bitmap.createBitmap( sourceBitmap, x, y, 80, 80, mMatrix, true);
但在角落区域显示错误:
java.lang.IllegalArgumentException:x 必须 >= 0
附图显示了我的预期结果
最佳答案
ImageView imageView = (ImageView) findViewById(R.id.iv_imageview);
imageView.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
int topParam = imageView.getPaddingTop();
int rightParam = imageView.getPaddingRight();
int maxTopParam = topParam+imageView.getMaxHeight();
int maxRightParam = rightParam + imageView.getMaxWidth();
if(event.getX>topParam&&event.getX<maxTopParam){
//the x coordinate is in your image... do the same to Y
}
});
return true;
}
关于android - 当触摸 ImageView 时,我需要在 android 中的另一个 ImageView 中显示触摸区域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31405082/