What is frame layout in android | How to use frame layout in android studio

I know this topic is not very important but not a single thing is useless in the android development. Every thing has it's own specific use. In this article we will be going to discuss about the frame layout that is used in XML to make designing of front end in android studio.

Feeling bored! Let's quickly start the tutorial.

But Wait...If you are Urdu or Hindi speaker you can watch this video to quickly understand what the frame layout actually is ( and get rid of this boring  article reading process ). If you are an English speaker then you can continue reading this article and skip the video tutorial.





First of all let me explain you why frame layout is used. Frame layout actually used for holding a single widget inside it and it fit to the whole activity screen. But it rarely use in development.
What interesting thing you can do with frame layout , you can put two widget one over another or you can say that one in front of the other as you can see in the following picture.



In the design view in the above picture you can easily see the textview is over the user icon which is actually the Imageview widget. Looking not interesting? Examine if you want to make a photo gallery and over every photo you have to put capturing date  (what an awesome thought ) this could be done by this frame layout. Here is the source code of the above design


<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".Main3Activity">

    <ImageView        android:layout_width="match_parent"        android:layout_height="match_parent"        android:src="@drawable/user1"></ImageView>
    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Text here"        android:layout_gravity="center"        android:textSize="200dp"></TextView>
</FrameLayout>


Although there are a lot of different layouts like Constraint layout that also can do the same job.Then why this frame layout is needed. Well this could be ask from you guy's Let's test how much you have learn from this article. Leave a comment bellow. Also if you want to appreciate us you can subscribe to our YouTube channel by clicking on the subscribe button bellow. ( But it's not mandatory, subscribe only if you like to see my content on YouTube otherwise remember me in your prayer. )


Previous
Next Post »

Popular Posts