Say I'm developing a different layout for devices with screen size equal to or greater than 600dp.
I want to use the post android 3.2 resource qualifiers. I created a folder named layout-sw600dp
and put my layout there, but at the same time I could have created a folder named layout-w600dp
and put the layout xml file there.
I'm trying to figure out what is the difference between -sw600dp
and -w600dp
? After all they are both meant to use the layout for device of width >= 600dp.
Asked
Active
Viewed 1.0k times
36

Vadim Kotov
- 8,084
- 8
- 48
- 62

user1409534
- 2,140
- 4
- 27
- 33
1 Answers
86
sw
is "smallest width". It doesn't change if the device is rotated.
w
, on the other hand, is available (i.e. current) width.
See Providing Alternative Resources:
smallestWidth -
sw<N>dp
- The smallestWidth is a fixed screen size characteristic of the device; the device's smallestWidth does not change when the screen's orientation changes.Available width -
w<N>dp
- This configuration value will change when the orientation changes between landscape and portrait to match the current actual width.
Example. Say that you have a device that is 600dp x 400dp.
- If you have a w600dp resource, it will be used in landscape, but not in portrait.
- If you have a sw600dp resource, it will not be used for any orientation (smallest is 400).

matiash
- 54,791
- 16
- 125
- 154
-
1Thank u for your answer. But I still don't get it. what do u mean by width is not changed if deviced is rotated. the width is changed – user1409534 Jul 04 '14 at 19:00
-
2@user1409534 Yes, but not the _smallest_ width. Edited answer with example, hope it's helpful. – matiash Jul 04 '14 at 19:02
-
~"**but not in portrait**". Actually, both portrait and landscape will be used for calculating width in **w
dp** – IgorGanapolsky Jan 29 '19 at 15:49