7.3.6. fragment_doodle.xml Layout for DoodleFragment

The fragment_doodle.xml layout for the DoodleFragment contains a FrameLayout that displays the DoodleView. In this section, you’ll create DoodleFragment’s layout and the DoodleView class. To add the fragment_doodle.xml layout:

1. Expand the project’s res/layout node in the Package Explorer.

2. Right click the layout folder and select New > Android XML File to display the New Android XML File dialog.

3. In the dialog’s File field, enter fragment_doodle.xml

4. In the Root Element section, select FrameLayout, then click Finish.

5. From the Palette’s Advanced section, drag a view (with a lowercase v) onto the design area.

6. The previous step displays the Choose Custom View Class dialog. In that dialog, click Create New... to display the New Java Class dialog.

7. In the Name field, enter DoodleView. Ensure that Constructors from superclass is checked, then click Finish. This creates and opens DoodleView.java. We’ll be using only the two-argument constructor, so delete the other two. Save and close DoodleView.java.

8. In fragment_doodle.xml, select view1 in the Outline window. In the Properties window’s Layout Parameters section, set Width and Height to match_parent.

9. In the Outline window, right click view1, select Edit ID..., rename view1 as doodleView and click OK.

10. Save and close fragment_doodle.xml.

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

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