Android - View (UI Widget|Component)

Card Puncher Data Processing

About

A view represents a a widget.

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:

If you want to group simple widgets, you need a container descending from a ViewGroup

ID

See reference/android/view/View.html

List

See design component

Properties

Visibility

Android Imageview Visibility

Dimension (Width and Height)

Width and height can have only two values:

  • wrap_content
  • or match_parent

There is then 4 possible combinations and possible outcomes when the view is in a parent (green)

Viewdimensionwidthheight

Gravity

Gravity of a view (Red) in a parent (green)

Viewgravity

Padding vs Margin

Android Padding Vs Margin

Type

Scroll

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.

Android Scroll View

List

see Android - ListView

Management

Get

by id

Button myButton = (Button) findViewById(R.id.my_button);
Task Runner