Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Arranging Views

The Android view hierarchy starts with a layout container. These containers hold the child views and arrange them relative to each other. There are several container types with different characteristics, optimizing them for different situations.

FrameLayout

The simplest layout container is the FrameLayout. This container does not arrange child views at all. It simply presents each view, one on top of the other. The order of the views is based on their declaration in the XML file: Views declared later in the file are drawn on top. Use this layout whenever you want to create overlapping views.

FrameLayout is especially useful when creating customized tappable elements. You can use the FrameLayout to pair a button with an ImageView, setting the button background to be transparent. This gives you more control over the padding and scaling of button images than just setting a background does.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial