Android 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.
All children of a LinearLayout are stacked one after the other, so a vertical list will only have one child per row, no matter how wide they are, and a horizontal list will only be one row high (the height of the tallest child, plus padding). A LinearLayout respects margins between children and the gravity (right, center, or left alignment) of each child
|android:id||android:id uniquely identify the layout|
|android:orientation||android:orientation specify the direction of arrangement of child View/ViewGroup and we will use "horizontal" for horizontal arrangement, "vertical" for vertical arrangements of child View/ViewGroup. The default is horizontal.|
|android:layout_weight||With android:layout_weight we can specify a size ratio between multiple views. E.g. you have a MapView and a table which should show some additional information to the map. The map should use 3/4 of the screen and table should use 1/4 of the screen. Then we will assign the android:layout_weight of the map to 3 and the android:layout_weight of the table to 1.|
|android:weightSum||android:weightSum is the weight sum of its all child View/ViewGroup.|
Android LinearLayout file of above example is given below:
Now let's design a login screen using Android LinearLayout. Create a Android Studio project with name Login under a package xyz.apnatutorial.linearlayout with a empty screen.
Here is the content of modified files.