5.4.7. activity_main.xml Layout for Phone and Tablet Portrait Orientation

In this section, you’ll create the layout for the MainActivity (Section 5.5) that will be used in portrait orientation on all devices. You’ll define the landscape orientation layout for tablets in Section 5.4.9. To create this layout—which will display only the QuizFragment (Section 5.6)—perform the following steps:

1. In the project’s res/layout folder, open activity_main.xml.

2. From the Palette’s Layouts section, drag a Fragment onto the RelativeLayout node in the Outline window.

3. In the Choose Fragment Class dialog, click Create New... to display the New Java Class dialog.

4. In the dialog’s Name field, enter QuizFragment, then click Finish to create the class. The IDE opens the Java file for the class, which you can close for now.

5. In activity_main.xml, select the QuizFragment in the Outline window, then set its Id to @+id/quizFragment and, in the Layout Parameters properties, set Width and Height to match_parent.

6. Save activity_main.xml.

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

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