LinearLayout - An Android ViewGroup
LinearLayout is an android view group which extends ViewGroup.java class. This layout is part of the Android framework which provides out of box functionality to position views in particular order.
Provides a way to stack all the child views in either vertically or horizontal order i.e it will always have 1 view each row.

Known direct subclasses
ActionMenuView, NumberPicker, RadioGroup, SearchView, TabWidget, TableLayout, TableRow, ZoomControlsList of attributes available with LinearLayout:
View attributes:
android:orientation- Can be one of the predefined keywords (vertical , horizontal)
- Specifies how children will be laid out - either vertically stacked or horizontally stacked. It is a compulsory attribute.
- E.g android:orientation=“vertical”
- Can be integer or float values.
- Defines maximum weighted sum. It defines the maximum sum of all the weights given to the child views.
- E.g: android:weightSum=“0.5”
- Can be one of the predefined keywords. Possible multiple values as well. Refer https://developer.android.com/reference/android/widget/LinearLayout#attr_android:gravity all the available keywords
- Specifies how the child views are positioned on both X and Y axes within its bounds.
- E.g android:gravity=“bottom|center_horizontal”
- Can be drawable (either a drawable resource or theme attribute) or color value in “#rgb", "#argb", "#rrggbb", or “#aarrggbb” formats.
- Specifies the UI of the divider shown. Has to work along with android:showDividers attributes which specifies whether the divider should be shown or not.
Layout attributes:
android:layout_gravity- Can be one of the predefined keywords. Possible multiple values as well. Refer https://developer.android.com/reference/android/widget/LinearLayout#attr_android:gravity all the available keywords
- Specifies how the component will be placed with respect to its siblings.
- E.g android:layout_gravity=“bottom|center_horizontal”
- Can be integer or float values.
- Specifies how much extra space should be given to the child view. If multiple views are available with these attributes space is accordingly divided based on the value of the weight.
- android:layout_weight=“0.5”
List of all the LinearLayout Attributes
Source: /Android/sdk/platforms/android-30/data/res/values/attrs.xml
Resources
- https://developer.android.com/reference/android/widget/LinearLayout.LayoutParams
- https://developer.android.com/guide/topics/ui/layout/linear

Comments
Post a Comment