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).