GetLocationOnScreen () returns unexpected values

I have a toolbar in the application with a search icon. Clicking on the search icon opens the search layout (FrameLayout).

I am trying to add a circular disclosure animation that will start in the center of the pressed icon. To find the coordinates of the icons, I use getLocationOnScreen (), and then calculate the center using its width and height.

Calling getLocationOnScreen () as a search icon (menu item) returns the center left point: enter image description here

Calling getLocationOnScreen () on the X icon (close) or the back icon returns the bottom left point: enter image description here

I thought he should bring back the top left corner, any ideas?

+5
source share

Source: https://habr.com/ru/post/1261653/


All Articles