Reputation: 196
Using View.getLocationOnScreen()
can get the coordinate, but it is a little larger than I expected, so I think the coordinate I get is relative to the full screen (which including ActionBar
) .
Is there any method can I get the coordinate without includig ActionBar
?
See the picture below.
Upvotes: 4
Views: 1151
Reputation: 220
please first see this image:
This link show you how get the current position of button(110 in picture)
How to get the absolute coordinates of a view
The second link calculate the Actionbar height(72 in picture)
How to get the ActionBar height?
And the last link show you how to calculate the Statusbar(38 in picture)
Height of status bar in Android
And now you can get the current position with this equal(110 = 72 + 38)
Hope to help you.
Upvotes: 1