I have been trying to find out how android relocates UI elements on different screens for the same application. I’ve been doing some tests with Android 2.2’s music player:

(source: simplehelp.net)
Here is the position(top left corner) for the first image button of the MediaPlaybackActivity in different screen sizes:
Screen 1 (resolution: 480×800, density: 240dpi): coordinates in px: 345, 109
Screen 2 (resolution: 240×400, density: 120dpi): coordinates in px: 173, 53
Screen 3 (resolution: 320×480, density: 160dpi): coordinates in px: 230, 46
My question is: given the coordinates of a UI element (the button in this case) in any screen, is it possible to predict the coordinates of that element on the other two screens?
I’ve tried converting from px to dp and then back to px but it doesn’t work (though is close), here is what I’ve tried:
location of image button with index 0 in screen 2 in px: 173, 53
location of image button with index 0 in screen 2 in dp: 230.66, 70.66 () (I use this formula: px = dp * (dpi / 160) which I found here)
location of image button with index 0 in screen 1 in px: 346, 106
You can see that here is quite close but when using this same formula to convert px from screen 1 to screen 3 I get: 230, 72.66, so you can see that the difference in the y axis is quite big. I suppose the upper bar affects the y axis but I don’t understand why such a difference.
I’m I doing something wrong here? is there a way to predict the new location and size of UI elements?, how does Android relocates the views?
Thanks in advance.
I think I know why the calculation failed. I created a simple app and let android do the scaling by itself, then applied the formula and it worked. So I guess that the application I was using (music player) might be customized to display differently on different screens, even though it looks quite the same. And since developers can used different layouts for different screens then I guess the problem is not as simple as I thought.
Thanks @aprian, your comment helped me to find out what might be the issue.