2014-06-30 2 views
0

ImageView 내부의 이미지 좌표를 찾으려고하지만 정확한 결과를 얻을 수있는 방법을 찾을 수 없습니다. 지금까지 내가 찾은 최고의 해결책이있다.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 값을 얻는 방법 및/또는이 좌표를 가져 오는 더 깨끗한 방법에 대한 제안? 미리 감사드립니다.

답변

0

getLocationOnScreen()에서 Y 값은 상태 및 알림 표시 줄 높이를 포함합니다. 이것을 제외하려면 link ..