Configuration qualifiers
We have already seen configuration qualifiers such as layout-large
or layout-xhdpi
in The Android Studio guided tour section from Chapter 3, Exploring Android Studio. Here, we will refresh and expand our understanding of them.
We can begin to remove the reliance on the controller layer to influence the app layout by using configuration qualifiers. There are configuration qualifiers for size, orientation, and pixel density. To take advantage of a configuration qualifier, we simply design a layout in the usual way that is optimized for our preferred configuration and then place that layout in a folder with a name that Android recognizes as being of that particular configuration.
So, if we want to have a different layout for landscape and portrait, we would create a folder called layout-land
in the res
folder and place our specially designed layout within it. When the device is in the portrait position, the regular layout from the layout
folder would be used, and when...