android.view.View Class - Base of User Interface Components
This section describes the android.view.View class which is the basic building block for all user interface components. Android SDK provides over 50 different specific views based on the android.view.View class to help you develop GUI (Graphical User Interface) applications.
android.view.View class is the basic building block for user interface components.
A android.view.View object occupies a rectangular area on the screen and is responsible for drawing and event handling.
android.view.View class is the base class for other user interface components like buttons, text areas, etc.
Multiple android.view.View objects can be arranged on the screen based on layouts.
Multiple android.view.View objects can be nested into trees.
One application usually has a single android.view.View tree.
A android.view.View object has the following basic properties:
- Size - The width and height of the view in unit of pixels.
- Position - The horizontal and vertical coordinates of the top-left corner of the view in its parent view.
- Padding - The empty space between edges and the content of the view.
- Parent - The parent view.
- Visibility - Indicator of view's visibility.
- Background - View's background.
The Android SDK provides a number of specific view objects as subclasses of the android.view.View class.
Some commonly used view subclasses are:
- ImageView - Displays an arbitrary image, such as an icon.
- KeyboardView - Renders a virtual Keyboard.
- ProgressBar - Displays a visual indicator of progress in some operation.
- Space - Displays an empty space that may be used to create gaps between components in general purpose layouts.
- SurfaceView - Provides a dedicated drawing surface embedded inside of a view hierarchy.
- TextView - Displays text to the user and optionally allows them to edit it.
- TextureView - Displays a content stream, such as a video.
- ViewGroup - Represents a special view that can contain other views as children.
The view group is the base class for layouts and views containers.
- ViewStub - Represents a special view that is initially invisible with zero size, and can inflated later at runtime.
- AutoCompleteTextView - Displays an editable text view that shows completion suggestions automatically while the user is typing.
- Button - Represents a push-button widget.
- CalendarView - Represents a calendar widget for displaying and selecting dates.
- CheckBox - Represents a checkbox with two-states that can be either checked or unchecked.
- Chronometer - Represents a simple timer.
- DatePicker - Represents a widget for selecting a date.
- EditText - Represents a thin veneer over TextView that configures itself to be editable.
- ExpandableListView - Represents a view that shows items in a vertically scrolling two-level list.
- FragmentBreadCrumbs - Displays "bread crumbs" representing the fragment stack in an activity.
- FrameLayout - Blocks out an area on the screen to display a single item.
- Gallery - Shows items in a center-locked, horizontally scrolling list.
- GestureOverlayView - Represents a transparent overlay for gesture input that can be placed on top of other widgets or contain other widgets.
- GridLayout - Places its children in a rectangular grid.
- GridView - Shows items in two-dimensional scrolling grid.
- HorizontalScrollView - Represents a layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display.
- ImageButton - Displays a button with an image (instead of text) that can be pressed or clicked by the user.
- LinearLayout - Represents a layout that arranges its children in a single column or a single row.
- ListView - Represents a view that shows items in a vertically scrolling list.
- MediaController - Represents a view containing controls for a MediaPlayer.
- NumberPicker - Represents a widget that enables the user to select a number form a predefined range.
- PagerTitleStrip - Represents a non-interactive indicator of the current, next, and previous pages of a ViewPager.
- RadioButton - Represents a radio button is a two-states button that can be either checked or unchecked.
- RadioGroup - Creates a multiple-exclusion scope for a set of radio buttons.
- RelativeLayout - Represents a layout where the positions of the children can be described in relation to each other or to the parent.
- ScrollView - Represents a layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display.
- SearchView - Represents a widget that provides a user interface for the user to enter a search query and submit a request to a search provider.
- SeekBar - Represents an extension of ProgressBar that adds a draggable thumb.
- SlidingDrawer - Hides content out of the screen and allows the user to drag a handle to bring the content on screen.
- Spinner - Displays one child at a time and lets the user pick among them.
- StackView - Displays items as a stack.
- Switch - Represents a two-state toggle switch widget that can select between two options.
- TabHost - Represents a container for a tabbed window view.
- TabWidget - Displays a list of tab labels representing each page in the parent's tab collection.
- TableLayout - Represents a layout that arranges its children into rows and columns.
- TableRow - Represents a layout that arranges its children horizontally.
- TimePicker - Represents a view for selecting the time of day, in either 24 hour or AM/PM mode.
- ToggleButton - Displays checked/unchecked states as a button with a "light" indicator and by default accompanied with the text "ON" or "OFF".
- VideoView - Displays a video file.
- ViewAnimator - Represents a FrameLayout container that will perform animations when switching between its views.
- ViewFlipper - Animates between two or more views that have been added to it.
- ViewPager - Represents a layout manager that allows the user to flip left and right through pages of data.
- ViewSwitcher - Switches between two views, and has a factory from which these views are created.
- WebView - Displays web pages.
- ZoomButton - Displays a button with zoom in and zoom options.
- ZoomControls - Displays a simple set of controls used for zooming and provides callbacks to register for events.
Last update: 2015.
Table of Contents
About This Book
Installing JDK 1.8 on Windows System
Installation of Android SDK R24 and Emulator
Installing Apache Ant 1.9 on Windows System
Developing First Android Application - HelloAndroid
Android Application Package (APK) Files
Android Debug Bridge (adb) Tool
Android File Systems
Android 4.0.3 File Systems
AboutAndroid - Application to Retrieve System Information
android.app.Activity Class and Activity Lifecycle
►View Objects and Layout Resource Files
►android.view.View Class - Base of User Interface Components
View, ViewGroup, Layout, and Widget
What Is Layout Resource File?
AndroidView v1.0 - Creating a Layout in Java Class
AndroidView v2.0 - Creating a Layout in Resource File
AndroidView v3.0 - Referencing Views in Resource Files
AndroidView v3.1 - Layouts with Vertical Orientation
AndroidView v3.2 - Layouts with Horizontal Orientation
AndroidView v4.0 - Inserting Views to Parent Layout
Using "adb logcat" Command for Debugging
Build Process and Package File Content
Building Your Own Web Browser
Android Command Line Shell
Samsung Galaxy Tab 3 Mini Tablet
USB Debugging Applications on Samsung Tablet
Android Tablet - LG-V905R
USB Debugging Applications on LG-V905R Tablet
Android Phone - LG-P925g
USB Debugging Applications on LG-P925g Phone
PDF Printing Version