Difference between sw600dp and w600dp?

Please take a look at Screen Support

According to the documentations :

SW : The fundamental size of a screen, as indicated by the shortest dimension of the available screen area. Specifically, the device's smallestWidth is the shortest of the screen's available height and width (you may also think of it as the "smallest possible width" for the screen). You can use this qualifier to ensure that, regardless of the screen's current orientation, your application's has at least dps of width available for it UI.

while W : Specifies a minimum available width in dp units at which the resources should be used—defined by the value. The system's corresponding value for the width changes when the screen's orientation switches between landscape and portrait to reflect the current actual width that's available for your UI.

In my words :

SW : minimum distance between screen edges in dps your layout will run on, so if you use layout-sw600dp/ folder then all layouts inside it will only work on devices that has at least 600dp (width or height)

W : means your layout will work on any device with n dp width regardless of the height or maybe the device currently in landscape mode (in this case w would refer to the height .. since orientation differs between landscape and portrait)


Android device screens are rectangles. Rectangles have two sides, one shorter than the other. Let's call the short one A and the long one B.

-swNNNdp indicates "use these resources if A is greater than or equal to NNN dp in length"

-wNNNdp indicates "use these resources if the width of the device, as presently held, is greater than or equal to NNN dp"

When the user rotates the device between portrait and landscape, the width will change (to be A or B), but A (the shortest width) is always the same.

Tags:

Android

Layout