FrameLayout & LinearLayout in Android

  • (5.0)
  • | 4814 Ratings


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.

Frame Layout

Annotation- Description
 Frame Layout
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 setVisibility 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).

Want To Get Android Training From Experts? Enroll Now For Free Demo On Android Training


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.


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


Frequently Asked Android Interview Questions & Answers

Subscribe For Free Demo

Free Demo for Corporate & Online Trainings.

Ravindra Savaram
About The Author

Ravindra Savaram is a Content Lead at 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. Protection Status