android - 当触摸 ImageView 时,我需要在 android 中的另一个 ImageView 中显示触摸区域?

标签 android image-processing

我使用了这个方法:

croppedBitmap =Bitmap.createBitmap( sourceBitmap, x, y, 80, 80, mMatrix, true);

但在角落区域显示错误:

java.lang.IllegalArgumentException:x 必须 >= 0

附图显示了我的预期结果

Attached image is showing my expected Result

最佳答案

   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/

相关文章:

java - 当前 Java 的 OpenCL 实现是否提供跨平台支持以及在项目中使用的稳定性?

image-processing - 低分辨率运动视频中物体检测的最佳方法是什么?

android - 使用 AWS SNS 的 Firebase 云消息传递

iphone - iOS 5 : Image Filters

silverlight - 在 Silverlight 3 中使用 WriteableBitmap 调整图像大小

python - OpenCV - 从问卷中检测复选框的手写标记

android - 如何在 Material Design 工具栏上添加搜索按钮

Google Play 上可用的 Android 应用程序被盗,并可在具有不同应用程序 ID 的其他商店使用

java - 我应该什么时候创建新 Activity ?

java - 保存到内存 Android