I want to get the coordinates of ImageView , regardless of the size of the device.
Is there any possible way!
I tried to create a specific size for ImageView , even a specific size for Parent View , but it doesnโt work.
I tried the following possible ways.
int[] posXY = new int[2]; imageview.getLocationOnScreen(posXY); int MoveX = posXY[0]; int MoveY = posXY[1];
I also tried Matrix, but did not work.
Matrix m = imageview.getImageMatrix();
Tried the code below, but it also doesn't work. !!
I need to get the same {x, y} coordinates for all devices for the same point (Location).
final float[] getPointerCoords(ImageView view, MotionEvent e) { final int index = e.getActionIndex(); final float[] coords = new float[] { e.getX(index), e.getY(index) }; Matrix matrix = new Matrix(); view.getImageMatrix().invert(matrix); matrix.mapPoints(coords); return coords; }
Here is the draw method:
if I set the bitmap in the drawing, it is not suitable for the screen for all devices. If I set the image with the width and height of the display, I get different coordinates.
@Override public void draw(Canvas canvas) {
Any idea or help would be really helpful.
android canvas coordinates android-custom-view draw
Janmejoy
source share