O'Reilly logo

Android 5 Programming by Example by Kyle Mew

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

Adding animated widgets

As with many programming languages, design and functionality are dealt with more or less separately. We use XML to design our layouts and Java to provide them with functionality. Here, we will see how both of these are done and will deal separately with each.

Designing an XML layout

We will be using the graphical design view to construct this UI, but it is worth checking the text view from the tab at the bottom after each step, to see how the changes that we make are applied in XML.

  1. Open the Hello World project and then the activity_main.xml file.
  2. Click on the Design tab at the bottom to view the device preview.
  3. Drag a TextView control into the middle of the screen, like so:
  4. From the Palette on the left, drag and drop a Button ...

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