UI Basic Container Elements
- FrameLayout
- Blocks out an area on the screen to display a single item.
- Elements inside a FrameLayout are stacked on top of each other.
- Control the position of elements within a FrameLayout using
their layout_gravity.
- Attributes
- foreground - a drawable to draw over the content
- LinearLayout
- Arranges elements in a column or row (default is a row)
- Attributes
- orientation - vertical or horizontal
- ScrollView and HorizontalScrollView
- Contains a single element that can be scrolled.
- Attributes
- fillViewport - defines whether the scrollview should
stretch its content to fill the viewport
- TableLayout
- Rows and columns of elements.
- Contains a number of TableRow elements, each of which
contains its row elements.
- Attributes
- shrinkColumns - 0-based index of columns to shrink
to fit the table into it's parent.
- stretchColumns - 0-based index of columns to stretch
to fit the table into it's parent.
- collapseColumns - 0-based index of columns to hide
- ConstraintLayout
- All views are laid out according to relationships between sibling
views and the parent layout.
- Flat view hierarchy (no nested view groups)
- Requires special configuration of Studio, so we won't try it.
- Example
MainActivity.java
activity_main.xml