FrameLayout

FrameLayout is designed to block out an area on the screen to display a single item. Generally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other. You can, however, add multiple children to a FrameLayout and control their position within the FrameLayout by assigning gravity to each child, using the android:layout_gravity attribute.

public class FrameLayout extends ViewGroup
java.lang.Object
↳ android.view.View
  ↳ android.view.ViewGroup
    ↳ android.widget.FrameLayout


android:foregroundGravity: defines the gravity to apply to the foreground drawable. Default value of gravity is fill. We can set values in the form of "top", "center_vertical" , "fill_vertical", "center_horizontal", "fill_horizontal", "center", "fill", "clip_vertical", "clip_horizontal", "bottom", "left" or "right" .
It is used to set the gravity of foreground. We can also set multiple values by using "|". Ex: fill_horizontal|top .Both the fill_horizontal and top gravity are set to FrameLayout.

android:measureAllChildren: determines whether to measure all children including gone state visibility or just those which are in the visible or invisible state of measuring visibility. The default value of measureallchildren is false. We can set values in the form of Boolean i.e. "true" OR "false".


Create framelayout_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.appcompat.widget.AppCompatTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Left Top"
        android:layout_gravity="top"
        android:textSize="12pt" />

    <androidx.appcompat.widget.AppCompatTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right|top"
        android:text="Right Top"
        android:textSize="12pt" />

    <androidx.appcompat.widget.AppCompatTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center|left"
        android:text="Center Left"
        android:textSize="12pt" />

    <androidx.appcompat.widget.AppCompatTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center|right"
        android:text="Center Right"
        android:textSize="12pt" />


    <androidx.appcompat.widget.AppCompatTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:text="Right Bottom"
        android:textSize="12pt" />

    <androidx.appcompat.widget.AppCompatTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left|bottom"
        android:text="Left Bottom"
        android:textSize="12pt" />

</FrameLayout>