I have an ImageView
in the center of a constraint layout. I want to get its coordinates in the screen for animation. I have referred similar questions, but I always get 0 as the coordinate.
How can I get the coordinates?
What I have tried:
imageView.getTop();
imageView.getX();
imageView.getPivotX();
Rect rect = new Rect();
imageView.getGlobalVisibleRect(rect);
rect.centerX()
Note:
ImageView
is placed at the center using constraints and it is of dimension 40dp x 40dp (small image).