2

I provided different xml layouts (with same name) for different screen sizes - like layout-sw320dp, layout-sw480dp etc. But when I try to change some properties in the specific layout in order to adapt UI for different devices - for example layout_height, layout_width, paddingRight, topMargin and so on - it still doesn't look good. I suppouse that's because there is a screen sizes range (4-5") and different screen sizes read from layout-sw320dp. I tried on Galaxy S4 - 5" screen and on Galaxy S3 Mini - 4" screen. So on S4 evrything looks good but on S3 mini - doesn't - buttons are moved down, image not in the center. What am I doing wrong?

Thank you in advance!

Ravindra Kushwaha
  • 7,846
  • 14
  • 53
  • 103
user5866501
  • 483
  • 2
  • 5
  • 12

1 Answers1

1

Use dimens.xml to assign Widths,Margins,padding. This xml is available in res/values folder. for different devices u can create different dimens. It simalar to having differnt Images for differnt Devices.

Source

You have to create Different values folder for different screens . Like

values-sw720dp          10.1” tablet 1280x800 mdpi
values-sw600dp          7.0”  tablet 1024x600 mdpi
values-sw480dp          5.4”  480x854 mdpi 
values-sw480dp          5.1”  480x800 mdpi 
values-xhdpi            4.7”   1280x720 xhdpi 
values-xhdpi            4.65”  720x1280 xhdpi 
values-hdpi             4.0” 480x800 hdpi
values-hdpi             3.7” 480x854 hdpi
values-mdpi             3.2” 320x480 mdpi
values-ldpi             3.4” 240x432 ldpi
values-ldpi             3.3” 240x400 ldpi
values-ldpi             2.7” 240x320 ldpi

Check this Image :-

SAMPLE Project View

Community
  • 1
  • 1
Nidhin Prathap
  • 696
  • 5
  • 15
  • so I have to create not only layouts for different screens but also different dimens for different screens? But if I already declared Widths,Margins,padding in different layouts - why have I create dimens also? – user5866501 Feb 01 '16 at 10:10