Search code examples
androidxmlandroid-layoutscreen-resolution

Why is my layout not Density Independent?


My layout as shown below looks very different depending on what screen size it is projected on to. I'm aware I can improve this somewhat using different layouts for each screen size but considering I have followed the best practises described in the android multiple screen support documentation (using dps, no absolute layouts etc) I wasn't expecting the results to look this bad so I fear there is a further underlying problem.

Low-Res Screen

Mid-Res Screen

Hi-Res Screen

Code: http://pastebin.com/D96ue9sc


Solution

  • Your layout is fine and completely as I would expect it. You shouldn't mix up density independent pixels with fully dynamically layouts.

    DP just means that the value is calculated according the density types. The density itself has nothing to do with screen resolutions. 60dp are 60px on a mdpi device, it doesn't matter if the screen is full HD or just 480x360. But the result is, of course, very different because the calculated 60px are nothing on a HD screen but a lot on a small one.

    You have not other possibility but to provide different layouts according to the screen size/resolution.