What is the smallest possible screen size that will use sw-600dp layout?

535 Views Asked by At

I created layout-sw600dp/layout.xml and it was looking great on device A. But on device B this layout has melt and looks bad. I want to know how my layout looks in worst possible case scenario (exactly 600dp width screen)

I want to create emulator with that screen size, so I will 100% sure that my layout will be looking good on sw-600dp+ phones. Do you know what size it is?

Also, I would really appreciate and be happy if you could give me an advice how to support multiple screen sizes in a modern world.

P.S. I have pretty difficult layouts with 40+ buttons

1

There are 1 best solutions below

2
BlackHatSamurai On

The short answer to your question regarding the type of emulator you'd use for sw-600dp+: a 7" tablet. You can find more information here. The sw in sw-600dp is the smallest width qualifier. It means that it is only mean to be used for devices with 600dp, which is typically 7" tablets.

The longer answer to your question about how to make sure your app look good "in a modern world" is:

Rather than trying to figure out what is the "worst case scenario", you should design layouts for each of the different screen densities and device types that Android supports:

  • ldpi Resources for low-density (ldpi) screens (~120dpi).
  • mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
  • hdpi Resources for high-density (hdpi) screens (~240dpi).
  • xhdpi Resources for extra-high-density (xhdpi) screens (~320dpi).
  • xxhdpi Resources for extra-extra-high-density (xxhdpi) screens (~480dpi).
  • xxxhdpi Resources for extra-extra-extra-high-density (xxxhdpi) uses (~640dpi).

Per the Android docs:

To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8:12:16 scaling ratio between the six primary densities. For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screens, all the different sizes should be:

36x36 (0.75x) for low-density (ldpi) 48x48 (1.0x baseline) for medium-density (mdpi) 72x72 (1.5x) for high-density (hdpi) 96x96 (2.0x) for extra-high-density (xhdpi) 144x144 (3.0x) for extra-extra-high-density (xxhdpi) 192x192 (4.0x) for extra-extra-extra-high-density (xxxhdpi) Then, place the generated image files in the appropriate subdirectory under res/ and the system will pick the correct one automatically based on the pixel density of the device your app is running on:

res/ drawable-xxxhdpi/ awesome-image.png drawable-xxhdpi/ awesome-image.png drawable-xhdpi/ awesome-image.png drawable-hdpi/ awesome-image.png drawable-mdpi/ awesome-image.png

You would do the same thing for layouts, creating a specific layout for each of the various dimensions (be sure to put the layouts in the right directories: layout-xhdpi, layout-mdpi, etc.). Doing this will allow the device to select the correct image/layout based on the device the user is using.

If you have a 40+ button layout, you would create buttons for each layout using the above method, then create layouts for each device. It's tedious work, but it is the correct way to do layouts on Android devices.

TLDR; read the Android documents around supporting multiple screen sizes.