Android FrameLayout Example

The Android FrameLayout is one of the lesser used layouts in the Android system, but it definitely has its purposes. The main reason you’d use a FrameLayout is when you only want to show one View at a time inside that FrameLayout. You can think of the Views as if they were in a stack with the most recently added View at the top.
Let’s walk through a simple example. The following code will first draw a red square with width 250dp in the FrameLayout and then draw a white square with width 150dp in the FrameLayout. Since the white square comes after the red square, the white square will be drawn on top of the red square.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android=""
    android:orientation="vertical" >

    <!-- kvarela: Red square -->
        android:background="#FFFF0000" />

    <!-- kvarela: White square -->
        android:background="#FFFFFFFF" />

Here’s a screen shot:

FrameLayout Example
FrameLayout Example