5.4.9. activity_main.xml Layout for Tablet Landscape Orientation

In Section 5.4.7, you defined MainActivity’s portrait-orientation layout, which contained only the QuizFragment. You’ll now define MainActivity’s landscape-orientation layout for tablets, which will contain both the SettingsFragment and the QuizFragment. To create the layout, perform the following steps:

1. Right click the project’s res folder, then select New > Folder. In the Folder name field enter layout-large-land and click Finish. The qualifiers large and land ensure that any layouts defined in this folder will be used only on large devices on which the app is running in landscape orientation.

2. Right click the layout-large-land folder, then select New > Android XML File to display the New Android XML File dialog, then enter activity_main.xml in File field. In the Root Element section, select LinearLayout (Horizontal) and click Finish to create the layout file.

3. Select the LinearLayout and set its Base Aligned property to false.

4. From the Layouts section of the Graphical Layout editor, drag a Fragment onto the LinearLayout node in the Outline window. In the Choose Fragment Class dialog, select SettingsFragment and click OK.

5. Repeat Step 5, but select QuizFragment and click OK.

6. Select the SettingsFragment node in the Outline window. In the Layout Parameters section set Width to 0dp, Height to match_parent and Weight to 1.

7. Select the QuizFragment node in the Outline window. In the Layout Parameters section set Width to 0dp, Height to match_parent and Weight to 2.

Because the QuizFragment’s Weight is 2 and the SettingsFragment’s is 1, the QuizFragment will occupy two-thirds of the layout’s horizontal space.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.233.44