Linear Layout in Android

A Layout that arranges its children in a single column or a single row. The direction of the row can be set by calling setOrientation(). You can also specify gravity, which specifies the alignment of all the child elements by calling setGravity() or specify that specific children grow to fill up any remaining space in the layout by setting the weight member of LinearLayout.LayoutParams.

The default orientation is horizontal. For more details Click Here

LinearLayout arrange its children in Horizontal View or Vertical View Only.

Example:


    

or


    
    
    
    

Here we not set any orientation so it will be “Horizontal” by default. This will show
Hello Android

If we set orientation “Vertical” then


    
    
    
    

It will show
Hello
Android

this means start layout and
this means end layout

android:layout_width=”match_parent”
this means: layout_width-> width of layout(Layout Parameter).
match_parent-> this will take width of screen.
if we set wrap_content-> then it will take width of children.
if we set fill_parent-> then it will take width of screen.

android:layout_height=”match_parent”
this means: layout_height-> height of layout(Layout Parameter).
match_parent-> this will take height of screen.
if we set wrap_content-> then it will take height of children.
if we set fill_parent-> then it will take height of screen.

Leave a Reply