O'Reilly logo

Android Application Development For Dummies, 2nd Edition by Donn Felker, Michael Burton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required