Support Multiple Screen Sizes – Android Studio Tutorial



Android devices come in all shapes and sizes, so your app’s layout needs to be flexible. That is, instead of defining your layout with rigid dimensions that assume a certain screen size and aspect ratio, your layout should gracefully respond to different screen sizes and orientations.By supporting as many screens as possible, your app can be made available to the greatest number of users with different devices, using a single APK.

And in this video I’m going to show you how your application can fit on different screen resolutions by creating layout files for each screen density.The pixel density is the number of pixels within a physical area of the screen and is referred to as dpi (dots per inch).

This is different from the resolution, which is the total number of pixels on a screen.To ensure that your layout is flexible and adapts to different screen sizes, you should use “wrap_content” and “match_parent” for the width and height of most view components, instead of hard-coded sizes.

Download Background Vector:

🏆 My Courses:
(GET 2 MONTHS MEMBERSHIP FOR FREE)

OR

💎 My Google Play Store:

💡 My Portfolio:

48 Replies to “Support Multiple Screen Sizes – Android Studio Tutorial”

  1. MockingSpy HD

    Guys, I have created Low Density, then I install 2 device which is LDPI, but each other have different layout design and didn't match the layout which I created. why? how support all resolutions?

  2. Sreehari K

    Isn't that a bad idea to create different layouts for different screen densities, because one simple change in one activity has effect on 4+ files, Isn't it ok to properly constraint and design for all densities? the same can be achieved via dimens.xml, that's how I have been done for my last few projects. I have made layout variants in extremely necessary cases such as for some landscape orientations, layout for tabs,etc..

  3. Ranjeet Kumar yadav

    This is just too long process. You can just make different dimension classes only in which u define the different sizes for different dimension sizes (hdpi ,mdpi ..xxhdpi…). No need to make different XML files for every dimension.

  4. M W

    thanks for the video 🙂 I have one question. Is it really important to save background file as .svg? Won't it work on .png?

  5. Un_Known

    Should I repeat this method for any layout for example if I made Recycleview when I made the custom layout for it should I make it 4 times hdpi and xhdpi …

  6. Aritra Bhattacharya

    great tutorial. But wouldn't it be better to use ratios and constraints along with vector drawables rather than creating same screen for each dpi? In that way the UI will always scale according to the ratios and fit all devices

  7. LittleGhostPro

    I added all different screen sizes but when i run my project the main_activity.xml is never used! I tried multiple devices in the emulator but never managed to use it! should I delete the main_activity.xml ?!

Leave a Reply

Your email address will not be published. Required fields are marked *