Support Multiple Screen

Now a day the biggest challenge of the app is compatibility. So that’s why I am putting this post to help people.

For Old day, we used to create different layout folder such as layout-small, layout-normal, layout-large, layout-xlarge for multiple screen. But that is a hell lot of work. So there is a new way to support multiple screen. Details are given below.

For Support Multiple Screen (All Mobiles and Tablets):

  • For Mobiles : We generally using different values folders for different dpi and inside that values folders only the “dimens.xml” file is different because when we are using different devices only the dimension is changed other than that all the parameters for example colors, strings, styles etc. are same.
    • For values folders: There are total 4 values folders.
      1. values                                          (For mdpi devices)
      2. values-hdpi                                 (For hdpi devices)
      3. values-xhdpi                               (For xhdpi devices)
      4. values-xxhdpi                             (For xxhdpi devices)

(here Inside each folder only dimens file is different so except dimens file, keep all other files only in values folder.)

  • For Tablets : We have to use sw (smallestWidth) concept. For example sw600dp means the system will use these resources only when the smallest dimension of available screen is at least 600dp.
    • The device’s smallestWidth does not change when the screen’s orientation changes.
    • Generally we create two values folders inside res folder for tablets:
      • values-sw600dp                       (For 7″ to 9″ Screen)
      • values-sw720dp                       (For 10″ to above screen)
  •  One last thing, Images for any device (Mobiles or Tablets) you have to create different drawable folders:
    • drawable-mdpi
    • drawable-hdpi
    • drawable-xhdpi
    • drawable-xxhdpi
    • drawable-nodpi

Leave a comment