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.
Create a new layout resource file named
res/layout/frame_layout.xml
.Declare the root element as a
FrameLayout
consuming all available space:<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent">
Inside the
FrameLayout
, create anImageView
to serve as the background image. It should scale to fill all the available space:<ImageView android...