Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does FrameLayout do?

I'm new to programming. I was using Graphical Layout then when I was reading xml file, I saw FrameLayout. Then I searched, but I couldn't find something useful. What is FrameLayout and what does it do?

like image 849
Amin Ghasemi Avatar asked Sep 05 '14 05:09

Amin Ghasemi


People also ask

What's the purpose of FrameLayout?

Android Framelayout is a ViewGroup subclass that is used to specify the position of multiple views placed on 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.

What is FrameLayout used for in Android?

FrameLayout is designed to block out an area on the screen to display a single item.

What's a FrameLayout When should you use FrameLayout instead of RelativeLayout?

A common rule of thumb when choosing layouts is to select the combination that results in the smallest number of nested layout views. Specific to your question, RelativeLayout is larger and more capable than the much simpler FrameLayout. So for simple layouts, the latter is probably more efficient.

What is RelativeLayout?

RelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent RelativeLayout area (such as aligned to the bottom, left or center).


1 Answers

You use a FrameLayout to stack child views on top of each other, with the most recent child on top of the stack. In the example below, the TextView is the most recent, so it is automatically placed on top of the ImageView.

For example:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical">      <ImageView         android:id="@+id/backgroundImage"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:scaleType="centerCrop"         android:src="@drawable/bitmapie" />      <TextView         android:id="@+id/descTextView"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_vertical"         android:layout_marginTop="70dp"         android:background="@android:color/holo_blue_light"         android:padding="10dp"         android:text="TextView placed at the top of the Imageview"         android:textColor="@android:color/white"         android:textSize="22sp" />  </FrameLayout> 

Output:

enter image description here

like image 168
Ojonugwa Jude Ochalifu Avatar answered Oct 12 '22 22:10

Ojonugwa Jude Ochalifu