Time for action - developing a FrameLayout example

To really understand what a FrameLayout does, and how it can be used, it's best to kick it around a bit with an example. In this example, we'll use a FrameLayout to layer some Button widgets on top of an ImageView, and show-and-hide a TextView message when one of the buttons is clicked.

For this example to work, you're going to need an image to serve as a background image. I'm going to use a photo of one of my friends. As always, place your image in the res/drawable directory, and try to use a PNG file.

  1. Create a new layout resource file named res/layout/frame_layout.xml.
  2. Declare the root element as a FrameLayout consuming all available space:
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.