Articles → Android → Linear Layout In Android

Linear Layout In Android






Purpose





Syntax


<LinearLayout   
android:layout_width=""    
android:layout_height=""    
android:orientation=" "></LinearLayout>





Layout_Weight Attribute







Gravity Attribute




<LinearLayout    
android:layout_width="400dp"
android:layout_height="200dp"
android:gravity="bottom"
android:orientation="horizontal"><Button        
    android:id="@+id/button2"        
    android:layout_width="wrap_content"        
    android:layout_height="wrap_content"        
    android:layout_weight="10"        
    android:text="Button" /><Button
    android:id="@+id/button"
    android:layout_width="wrap_content"        
    android:layout_height="wrap_content"
    android:layout_weight="4"
    android:text="Button" /></LinearLayout>




Picture showing the output of the linear layout in android
Click to Enlarge


Match_Parent Attribute





Nested Layout




Picture showing the nested layout in the component tree
Click to Enlarge



Picture showing the output of the nested layout
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, October 28, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250