FrameLayout & LinearLayout in Android

 

FrameLayout

FRAME LAYOUT is designed to display a single item at a time. You can have multiple elements within a Frame Layout but each element will be positioned based on the top left of the screen. Elements that overlap will be displayed overlapping. Let us see how this works.

If you would like to Enrich your career with an Android certified professional, then visit Mindmajix - A Global online training platform: “Android training” Course.This course will help you to achieve excellence in this domain.

<FrameLayout

android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<ImageView 

android:src="@drawable/icon"
android:scaleType="fitCenter"
android:layout_height="fill_parent"
android:layout_width="fill_parent"/

 

</FrameLayout>

MindMajix Youtube Channel

FrameLayout can become more useful when elements are hidden and displayed programmatically. You can use the attribute android: visibility in the XML to hide specific elements. You can call set visibility from the code to accomplish the same thing. The three available visibility values are visible, invisible (does not display, but still takes up space in the layout), and gone (does not display, and does not take space in the layout).

Checkout:-Android Services

LinearLayout

LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. You can specify the layout direction with the android: orientation attribute.

LinearLayout organizes elements along a single line. You specify whether that line is vertical or horizontal using android: orientation. Here is a sample Layout XML using LinearLayout.

<TextView
android:text="FirstName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>


<EditText
android:width="100px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

Here is a screenshot of the result of the above XML.

XML

Frequently Asked Android Interview Questions & Answers

 

Job Support Program

Online Work Support for your on-job roles.

jobservice

Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:

  • Pay Per Hour
  • Pay Per Week
  • Monthly
Learn MoreGet Job Support
Course Schedule
NameDates
Android TrainingNov 19 to Dec 04View Details
Android TrainingNov 23 to Dec 08View Details
Android TrainingNov 26 to Dec 11View Details
Android TrainingNov 30 to Dec 15View Details
Last updated: 01 Oct 2024
About Author

Ravindra Savaram is a Technical Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.

read less