【问题标题】:Finding accurate coordinates of an image inside of an ImageView在 ImageView 中查找图像的准确坐标
【发布时间】:2014-08-21 02:46:33
【问题描述】:

我试图在 ImageView 中查找图像的坐标,但找不到获得准确结果的方法。这是迄今为止我找到的最佳解决方案。

    int[] img_coordinates = new int[2];
    plate.getLocationOnScreen(img_coordinates);
    int x = img_coordinates[0];
    int y = img_coordinates[1];
    BitmapFactory.Options o = new BitmapFactory.Options();
    o.inTargetDensity = DisplayMetrics.DENSITY_DEFAULT;
    Bitmap bmp = BitmapFactory.decodeResource(this.getResources(), R.drawable.plate_only, o);
    int w = bmp.getWidth();
    int h = bmp.getHeight();

x 值对此是正确的,但 y 正在返回图像上半部分中间的值。关于如何获得准确的 y 值和/或获得这些坐标的更清洁方法的任何建议?提前致谢。

【问题讨论】:

    标签: android imageview coordinates


    【解决方案1】:

    在 getLocationOnScreen() 中 Y 值包括状态和通知栏高度。 要排除此问题,您可以从此 link.. 获得帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-05
      • 1970-01-01
      • 2013-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多