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.
Here’s a screen shot:
You must log in to post a comment.