Android Framelayout is a ViewGroup subclass which is used to specify the position of multiple views placed on the top of each other to represent a single view screen.
Generally, we can say FrameLayout simply blocks a particular area on the screen to display a single view. Here, all the child views or elements are added in stack format means the most recently added child will be shown on the top of the screen.
But, we can add multiple children view and control their positions only by using gravity attributes in FrameLayout.
The FrameLayout can be defined using the code below:
In this file, we declare the FrameLayout and start adding multiple view like textView, editText, and Button etc. All the view are placed on each other but we displace according to our requirement.
First, we add an image in the background and add other widgets on the top. On the screen, we can see the beautiful login page having an image in the background.
When we have created layout, we need to load the XML layout resource from our activity onCreate() callback method and access the UI element form the XML using findViewById.
We need to run using Android Virtual Device(AVD) to see the output.
- Android TableLayout in Kotlin
- Android EditText in Kotlin
- Android Fade In/Out in Kotlin
- Android RelativeLayout in Kotlin
- Android ListView in Kotlin
- Android LinearLayout in Kotlin
- Android Slipe Up/Down in Kotlin
- Android Toast in Kotlin
- How to create project in Android Studio using Kotlin
- Android Menus
- Android UI Layouts
- Android Architecture
- Introduction to Android Development
- Android Project folder Structure
- How to install Android Virtual Device(AVD)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.