سؤال

I build a aplication supputing all the diferent sizes of screans (ldpi, mdpi, hdpi, xhdpi and xxhdpi). The problem is that when I run my application on the Sony Xperia P (Sony Xperia LT22i 540 x 960 pixel - 4") the layout satay a mess. In what folder do I have to put the layout from to this device? And how to prevent to happen this mess againg with another device?

UPDATE

I did diferents layouts xml for diferents folders.

هل كانت مفيدة؟

المحلول

Please read about Using LinearLayout

If you use LinearLayout correctly you can have even one Layout that can fit ALL screen sizes..

نصائح أخرى

You should create a folder with layout-(small|normal|large|xlarge) and put your XML layout here.

ldpi, mdpi, hdpi, xhdpi and xxhdpi refer to the images not for layouts.

Read here for more info.

In your case, you could create a layout-w540dp-h960dp folder.

Available screen width wdp

Examples: w720dp w1024dp

Specifies a minimum available width in dp units at which the resources should be used—defined by the value. The system's corresponding value for the width changes when the screen's orientation switches between landscape and portrait to reflect the current actual width that's available for your UI.

This is often useful to determine whether to use a multi-pane layout, because even on a tablet device, you often won't want the same multi-pane layout for portrait orientation as you do for landscape. Thus, you can use this to specify the minimum width required for the layout, instead of using both the screen size and orientation qualifiers together.

and

Available screen height hdp

Examples: h720dp h1024dp etc.

Specifies a minimum screen height in dp units at which the resources should be used—defined by the value. The system's corresponding value for the height changes when the screen's orientation switches between landscape and portrait to reflect the current actual height that's available for your UI.

Using this to define the height required by your layout is useful in the same way as wdp is for defining the required width, instead of using both the screen size and orientation qualifiers. However, most apps won't need this qualifier, considering that UIs often scroll vertically and are thus more flexible with how much height is available, whereas the width is more rigid.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top