App Layout
Learn about various layout types to design Android apps.
An Android app comprises one or more activities. Each activity represents a single screen that has a user interface. Each screen in our app has controls from different layouts, which define a visual structure of an activity or an app widget. Layouts specify a set of rules to place control elements, such as buttons, input fields, text fields, etc., on a view. Let’s explore various Android views and layouts.
Views and layouts
A View
is an object that represents a single UI component, such as a button, text box, or image, while a Layout
is a container that holds and organizes multiple views in a particular arrangement.
A Layout
organizes multiple views on the screen by defining their relative positions and sizes. An Android layout XML file specifies views and layouts as nested elements, with each Layout
containing one or more views. The arrangement and appearance of the views are determined by the properties and attributes specified in the Layout
.
The View
class
The View
class is a basic building block for UI components. A View
object takes a rectangular screen area. Its main responsibility is to draw elements and handle events. We can create UI components such as buttons and text fields using the View
class. The View
is the superclass (base class) of the ViewGroup
class, which is a superclass for layouts. The following figure shows some common views and layouts and their relationships.
Get hands-on with 1400+ tech skills courses.