Base user interface components in Android
The following description gives an overview of the most important user interface related component and parts of an Android application.
Activities are the base for the user interface in Android. They have already been introduced in Section 8.4, “Activity”.
Fragments are components which run in the context of an activity. A fragment encapsulates application code so that it is easier to reuse them and to support devices of different size.
The following picture shows an activity called MainActivity. On a smaller screen it shows only one fragment and allows the user to navigate to another fragment. On a wide screen it shows those two fragments immediately.
Views and layout manager
Views are user interface widgets, e.g., buttons or text fields. Views have attributes which can be used to configure their appearance and behavior.
A ViewGroup is responsible for arranging other views. It is also known as layout manager. The base class for these layout managers is the
android.view.ViewGroup class which extends the
android.view.View class which is the base class for views.
Layout managers can be nested to create complex layouts.
Home screen widgets and wallpaper
Widgets are interactive components which are primarily used on the Android home screen. They typically display some kind of data and allow the user to perform actions with them. For example, a widget can display a short summary of new emails and if the user selects an email, it could start the email application with the selected email.
To avoid confusion with views (which are also called widgets), this text uses the term home screen widgets, if it speaks about widgets.
Live wallpapers allow you to create animated backgrounds for the Android home screen.