3

I have an app that I need to ensure different devices are pulling from different layout folders. I need a nexus 5 (1920 x 1080) to pull from a different folder than a Note 4 (2560 x 1440).

Currently, no matter what combination of folder names, they both pull from the same folder.

I have tried:

layout-xxhdpi & layout-xxxhdpi 

(they both pull from xxhdpi)

layout-sw320dp & layout-xxhdpi

(they both pull from layout-sw320dp

layout-large & layout-xlarge

(they both pull from layout-large)

What would be the proper layout folder convention for this situation?

DeNitE Appz
  • 1,003
  • 2
  • 12
  • 18

4 Answers4

1

Actually you need to add the following folders:

  • layout-sw320dp (xhdpi devices)
  • layout-sw340dp (xxhdpi devices)
  • layout-sw380dp (xxxhdpi devices)

you must add folders only if you really need another whole layout in different devices. Other than that , use only default layout folder with proper layout structure and extract dimensions on different density folders.

Helmi
  • 556
  • 2
  • 19
1

So this seems to be the only arrangement that worked for me...

layout (Nexus 4 & 5)

layout-sw440dp-port (Note 4, Nexus 6)

layout-sw720dp-port (Samsung 10" tablet)

(It I take off the "port" it doesn't work...) ;-)

Thanx for all the suggestions!

DeNitE Appz
  • 1,003
  • 2
  • 12
  • 18
0

According to Google device metrics, Note 4 and Nexus 5 both have xxhdpi density, but their widths and heights are different, so you should try playing with the smallestWidth qualifier. For example with this combination should work: layout-sw360dp & layout-sw480dp (You can read more about qualifiers here)

Gex
  • 2,092
  • 19
  • 26
-1

This is the structure:

    res/layout
    res/layout-large
    res/layout-xlarge
    res/layout-sw600dp
    res/layout-sw720dp
    res/layout-sw800dp
josedlujan
  • 5,357
  • 2
  • 27
  • 49