All the UI elements extends from the view class
- a container (viewgroup) is a subclass of a view object
- a simple widget is also a subclass of a view object.
Views are rectangle on the screen (same concept than box in CSS) where you may or may not view the borders.
A View occupies a rectangular area on the screen and is responsible for:
- and event handling.
If you want to group simple widgets, you need a container descending from a ViewGroup
See design component
Dimension (Width and Height)
Width and height can have only two values:
- or match_parent
There is then 4 possible combinations and possible outcomes when the view is in a parent (green)
Gravity of a view (Red) in a parent (green)
Padding vs Margin
ScrollView: Extension of the FrameLayout class (meaning you should place one child in it containing the entire contents to scroll) that allows the user to scroll vertically to reveal more content than can be displayed on screen at once. The ScrollView is often used to contain a vertically oriented LinearLayout into which you can place any linear layout that in turn arranges each item it contains into a vertical list.
Button myButton = (Button) findViewById(R.id.my_button);