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);





Discover More
Androidadapteritemviewtype
Android - Adapter

An android/widget/AdapterAdapter (widget) object acts as a bridge between: an AdapterView (An android/widget/AdapterViewAdapterView is a view whose children are determined by an Adapter. See subclasses...
Card Puncher Data Processing
Android - Custom View

Custom view To get access to the AccessibilityManager instance, use this code: topics/graphics/2d-graphicsCanvas and Drawables guide custom-views/custom-drawingCustom Drawing guide. ...
Card Puncher Data Processing
Android - Event Handling

Views object handle events. with: a list view a toast when an item on the list is clicked
Card Puncher Data Processing
Android - FrameLayout

FrameLayout is great for simple layouts when you only haveone child to view, like a list View that fills the entire content area
Android Ui Hierarchy
Android - GUI (Layout)

The graphical user interface for an Android app is built using a hierarchy of UI elements where: ViewGroup (Layout) objects are invisible container element (and therefore one is at the top). Layouts...
Px Vs Dpi Image
Android - ImageView

image view See For an DPI explanation, see multiple screen and Devices and Displays DPI Number Number of Pixel by Dpi MDPI...
Card Puncher Data Processing
Android - Inflate (a layout XML to a view UI object)

In Android, you can create an UI: decoratively through a layout XML with Java object view (viewgroup for container and views for widget) In this context, Inflate means reading a layout XML (often...
Android Xml Layout Attribute Reference
Android - Layout File (XML)

A layout XML is a declarative way of creating an UI. To define the GUI in android, you can do it: at runtime in the code with the ViewGroup object (UI container) and View obejct (widgets) at load...
Card Puncher Data Processing
Android - Settings (Preference)

Settings (UI Preference or Parameters) allow users to modify app features and behaviors and are implemented through the android/preference/PreferenceAndroid's Preference APIs See also Instead...
Card Puncher Data Processing
Android - Snackbar Widget

Snackbar is a view widget.



Share this page:
Follow us:
Task Runner