Developing the User Interface

Okay, it’s time to start developing the user interface. First make sure that you’re in XML view of your layout by clicking the activity_main.xml tab. When you’re in XML view, delete the XML and replace it with the following. Your layout should now look like this:

<?xml version=”1.0” encoding=”utf-8”?>

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”

android:orientation=”vertical”

android:layout_width=”match_parent”

android:layout_height=”match_parent”

>

</LinearLayout>

Viewing XML layout attributes

Before continuing, you need to understand the attributes of the Android layout XML you’re working with. See Table 4-3.

Table 4-3 XML Layout Attributes

Layout

What It Does

xmlns:android=”...”

Defines the XML namespace that you use to reference part of the Android SDK

android:orientation= ”vertical”

Informs Android that this view will be laid out vertically, such as in the portrait format in printing

android:layout_width= ”match_parent”

Informs the view that it should fill as much horizontal space as it can, up to its parent, to make its own width the same as its parent’s

android:layout_height= ”match_parent”

Informs the view that it should fill as much vertical space as it can, up to its parent, to make its own height the same as its parent’s

At this point, you have defined the layout to fill the entire screen by setting the width and height to “match_parent”.

Working with views

As stated ...

Get Android Application Development For Dummies, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.