0

I set up my Android application to support different screen resolutions (ldpi, mdpi, hdpi, xhdpi, ...) and that seems to be working as it should. Different screen heights on the other hand are not scaling correctly: I optimized my design to fit on the small screens (of the default Android Studio emulators) which means that there is a lot of empty space on longer devices. Is there any way to combine screen resolutions (xhdpi, ...) with screen lenght (long, ...)? If this is not possible at all I would really appreciate alternative methods of layout scaling in order to fix my problem. I currently use dp and RelativeLayouts only. Thanks in advance.

RL in the picture below represents RelativeLayouts.

short layout long layout layout structure supported resolutions

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
aignerbas
  • 45
  • 7

1 Answers1

1

I would suggest using multiple nested linear layouts while specifying layout weights to scale components on all kinds of displays (see this guide for example). Tip: You can use empty views to create dynamic spaces. Also in some cases it is useful to specify portrait and landscape layouts separately (see this guide) although then you have to manage some duplicate code.

Jan Málek
  • 531
  • 8
  • 21
  • I rebuilt one xml file with a lot of linear layouts and it seems to be working.. Thanks. But this way seems a bit excessive.. Is this the only way to do it? – aignerbas Feb 26 '20 at 20:56
  • 1
    @aignerbas I am not sure if it's clear from my answer: you can always use any other layout when it's more appropriate. When creating layouts with a lot of components I usually combine relative and linear layouts. I also believe It's a good practise to always try use as little nested layouts as possible to make the behaviour easier to read. – Jan Málek Feb 27 '20 at 07:40