FrameLayout
is designed to block out an area on
the screen to display a single item. 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.
Generally,
FrameLayout
is
used to hold a single child view. Common use cases are creating place holders
for inflating Fragments
in Activity
,
overlapping views or applying foreground to the views.
Example:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="@drawable/nougat"
android:scaleType="fitCenter"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
<TextView
android:text="FrameLayout Example"
android:textSize="30sp"
android:textStyle="bold"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:gravity="center"/>
</FrameLayout>
It will look like this:
No comments:
Post a Comment