Search code examples
androidandroid-layoutlayoutandroid-emulatornexus-5

Android emulator displays wrong layout for the google nexus 5 dimensions (1080x1920)


I am having some problems with layouts in my android application. I have created multiple android resource directories, for multiple android devices. The problem stands when I try to test my app on a nexus 5 emulator the screen's layout is out of bounds, it is disproportionate completely. In my app all the layouts for the layout-xxhdpi-1080-1920 seem completely alrigth, the problem arises when I start my app in an nexus 5 emulator. It seems that the emulator picks a different layout size and not the one is it supposed to.

And I also have one question reqarding layout creation. Is the any better way to cover as much android devices as possible, instead of making all layout resolutions: for example: -mdpi-460x800 , xhdpi-720x1290, xhdpi-1080x1920, and so on ... It really takes about more than 18 layout directory types and it is quite a lot.

I already looked at all the documentation Supporting different screens.


Solution

  • You could cover almost every android device in the world. To do this you need have device specific resources.

    for android versions earlier than 3.2

    layout-ldpi
    layout-mdpi
    layout-hdpi
    layout-xhdpi
    

    for android version 3.2 and higher

    layout-sw360dp
    layout-sw420dp
    layout-sw600dp
    layout-sw720dp
    

    This is just an representative example, more information here in android docs