Reputation: 75
Assume I have a large screen device and a small screen device, now if I touched the large screen device at some random x,y like this:
//on touch event
float x = event.getX();
float y = event.getY();
And send these to the smaller screen device, how do I know on the small screen device where that x,y coordinate must be?
In other words if it was at the top right corner on the larger screen device, it must be at the top right corner on the small screen device
Upvotes: 0
Views: 110
Reputation: 576
Most important for this is you need to have widths of both screens, and calculate it proportionally. Suppose largeWidth = 400, smallWidth = 300, and your x on Large screen is 200. Then if you have to calculate width on small screen, then simple math would help here.
smallX = x * smallWidth/LargeWidth
smallX = 200 * 300/400
smallX = 150
Upvotes: 1