Using configuration qualifiers – mini app
Create a new project and call it Configuration Qualifiers
and follow the next steps:
Right-click on the
res
folder in the project explorer and navigate to New | Android resource directory. Typelayout-land
and click on OK.Tip
If you don't see your new directory in the project explorer, you need to change the view of the project explorer through its drop-down selector at the top of the project explorer window. Click on the drop-down selector and choose Project.
In the
layout_main.xml
file, change the text of the default TextView widget fromHello world
toHello portrait!
.Right-click on the
layout-land
folder and navigate to New | Layout resource. Name the filelayout_main.xml
. Add a single Plain TextView widget and change thetext
property toHello landscape!
.Run the app and rotate the device between landscape and portrait orientations. Note that the OS automatically uses the appropriate version of
layout_main.xml
.
If we got a reference to TextView
(or...