I've created an OnTouchListener
for motion events in an activity, and I want to find where they happen relative to the screen.
I can use event.getRawX()
to find the x co-ordinate, and similarly windowManager.getDefaultDisplay().getMetrics(new DisplayMetrics())
or ...getSize(new Point())
to get the display dimensions.
The problem I'm having is that the display dimensions are consistently reporting the width as 1080, but the motionevents I receive return numbers greater than 1800 for getRawX()
.
Using the deprecated display.getWidth()
returns something close, around 1700 - but even this is lower than what's reported at the right edge of the screen.
I assume motion events use a different co-ordinate system to the display metrics - but how can I convert between the two?
Cheers
Nic