Android Frame Layout
Android Frame Layout
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.
Frame Layout
FrameLayout Attributes
Following are the important attributes specific to FrameLayout −
Example
This example will take you through simple steps to show how to create your own
Android application using frame layout. Follow the following steps to modify the
Android application we created in Hello World Example chapter −
package com.example.demo;
import android.os.Bundle;
import android.app.Activity;
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:src="@drawable/ic_launcher"
android:scaleType="fitCenter"
android:layout_height="250px"
android:layout_width="250px"/>
<TextView
android:text="Frame Demo"
android:textSize="30px"
android:textStyle="bold"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:gravity="center"/>
</FrameLayout>
Let's try to run our modified Hello World! application we just modified. I assume
you had created your AVD while doing environment setup. To run the app from
Android Studio, open one of your project's activity files and click Run
icon from the toolbar. Android Studio installs the app on your AVD and starts it and if
everything is fine with your setup and application, it will display following Emulator
window −