Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

How to define dimens.xml for every different screen size in android?

When we talked about supporting different screen size in Android. every one is focusing on creating different layouts for every possible screens.

  • ldpi
  • mdpi
  • hdpi
  • xdpi
  • xxdpi
  • xxxdpi

What i did is design a layout as per xhdpi screen reference and define it’s dimensions in dimens.xml Now i want to give support it to every possible android screen size. How can I do that?

Step 1

1. You have to create different values folder for Different values for different screens.
Go to Your Project / app / src / main / res.
Right click on res and create different values folder in it.

Step 2

2. Create folders named



Step 3

3. Create dimensions.xml file in values folders.
Different values for different screen size.

values-ldpi                     2.7" 240*320 ldpi
values-ldpi                     3.3" 240*400 ldpi
values-ldpi                     3.4" 240*432 ldpi

values-mdpi                     3.2" 320*480 mdpi

values-hdpi                     4.0" 480*800 hdpi
values-hdpi                     3.7" 480*854 hdpi

values-xhdpi                    4.7" 1280*720 xhdpi
values-xhdpi                    4.65" 720*1280 xhdpi

values-sw480dp                  5.1" 480*800 mdpi
values-sw480dp                  5.4" 480*854 mdpi

values-sw600dp                  7.0" tablet 1024*600 mdpi

values-sw720dp                  10.1" tablet 1280*800 mdpi

when you attach dimension.xml file with your layout than you will get direct effect with your screen size.
This will help you to set dimensions for all type of screens.