When designing the layout of my Android application, I always used dp (as they advise everywhere).

But when launched in Genymotion on different devices (with the same resolution!) Samsung Google Galaxy Nexus 720x1280 and Sony Xperia S 720x1280, I already have many elements displayed differently, to say nothing about devices with higher resolutions. Some elements in general under each other left.

What is the problem? How then to make applications with the same design on all devices?

    1 answer 1

    It is impossible to make the same design for all applications in dp. DiP (density-independent pixel) is literally a density-independent pixel. This value does not depend on the screen resolution of the device, but on the physical size.

    And try to see what the differences will be between the Nexus One and the Motorola Nexus, if with such minimal differences you have already crumbled.

    From the simplest - use LinearLayout , distribute the elements weight and see the result. From this and push off.

    • I found a lot of information that looks LinearLayout like with LinearLayout than with other markup. And what if my whole application is built on RelativeLayout ? It seems the problem is precisely this .. - ivanovd422
    • I also learned that with margin it is necessary to use both options for indenting with edges: Start + left / Right + end, since on different devices will display differently. can someone come in handy) - ivanovd422
    • With RelativeLayout , you can also live if you dance not only from the left edge, but also from the right and do not set the width of the controls exactly, but use layout_toLeftOf and layout_toRightOf . But with LinearLayout live easier and faster rendered. - Eugene Krivenja