O'Reilly logo

Android User Interface Development by Jason Morris

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

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

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