Please note that all View and Viewgroups are derived from view class
What is a View: A view is any object which draws something on User Screen(Activity) with which a user can interact. This may include a button,an image view, textbox,check box etc.
The
View
objects are usually called "widgets" and can be one of many subclasses, such as Button
or TextView
What is ViewGroup: A viewgroup is an invisible container which holds other views and viewgroups objects. A collection of related views and viewgroup forms a viewgroup object. The
ViewGroup
objects are usually called "layouts" can be one of many types that provide a different layout structure, such as LinearLayout
or ConstraintLayout
And android developer can declare a layout in two ways:
- Declare UI elements in XML. Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts. You can also use Android Studio's Layout Editor to build your XML layout using a drag-and-drop interface.
- Instantiate layout elements at runtime. Android app can create View and ViewGroup objects (and manipulate their properties) programmatically.
The Android framework gives the flexibility to use either or both of these methods to build your app's UI. For example, you can declare your app's default layouts in XML, and then modify the layout at runtime.
Android provide the following layouts which can be used to achieve the requirements of the apps.
1. Linear Layout
2. Relative Layout
3. Table Layout
4. Grid Layout
5. Frame Layout
6. Absolute Layout
7. Constraint Layout