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.