Question

In my android app I have a layout which contains many buttons and spinners. I have also added different layouts for the individual screen sizes (hdpi, xhdpi etc.). The problem is when testing my layout-hdpi in the emulator with the Nexus S (indicated as hdpi) it looks fine, but when testing it with Nexus One (also indicated with hdpi) the buttons are overlapping?? In the layouts all sizes are in dp! So shouldn't I receive the same result with two devices in hdpi?

Was it helpful?

Solution

I had the same problem what you should do is obtain the screen height:width ratio and name it, well ratio. so your ratio = height/width then instead of using the size of buttons or other elements in exact size in dp, take the size in the form of what part your element takes up in the view.

I think i confused you there, but its easy, see for example:

if you have an image that you want to add on the top half of the screen then dont say height=150dp or width=200dp you screen height was h so your image height would be h/2 and your width would then be h/ratio.

this would also work in the landscape mode, you wont have to find the buttons in the landscape mode because they were out of the screen.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top