Views and View Groups
Subclass Description
TextView Used to display text on the screen.
ImageView Used to display images or drawables.
Button Used to trigger actions when clicked.
EditText Used to accept user input as text.
CheckBox Used to represent a binary choice (checked or unchecked).
RadioButton Used to represent a single choice from a group of options.
ProgressBar Used to show the progress of an operation.
SeekBar Used to select a value from a range by sliding a thumb.
ListView Used to display a scrollable list of items.
A more flexible and efficient version of ListView for
RecyclerView displaying large datasets.
Basic Views
Key Concepts:
• Containers: ViewGroups are designed to hold and organize other View
and ViewGroup objects, allowing you to create complex and dynamic user
interfaces.
• Layout Managers: ViewGroups utilize layout managers (like
LinearLayout, RelativeLayout, ConstraintLayout) to determine how their
children are positioned and sized.
• Hierarchy: ViewGroups can be nested within other ViewGroups, creating
a hierarchical structure for your UI.
• Invisible Containers: ViewGroups themselves are not visible on the
screen; they are used to structure the visible View elements within them.
Android Layouts
In Android, layouts define the visual structure of a user interface. They
are essentially ViewGroups, which are containers that hold other views
and layouts, and they are defined using XML files. These layouts dictate
how different UI elements are arranged on the screen, allowing
developers to create complex and responsive user interfaces.
Here's a breakdown of common layout types in Android:
1. LinearLayout:
• Arranges child views in a single direction, either vertically or
horizontally.
• Useful for simple, linear arrangements.
2. RelativeLayout:
• Positions child views relative to each other or the parent layout.
• Allows for more complex and flexible arrangements.
3. FrameLayout:
• Designed to block out a space on the screen for a single view.
• Can be used to stack multiple views on top of each other.
4. ConstraintLayout:
• A powerful and flexible layout that allows for complex UI designs in a
flat hierarchy.
• Offers better performance and tooling support compared to nested
layouts.
5. TableLayout:
• Arranges child views into rows and columns, like a table.
• Not recommended for new projects due to performance concerns,
ConstraintLayout is a better alternative.
6. ScrollView:
• Allows users to scroll through content that exceeds the screen size.
• Can contain only one child view, typically a LinearLayout.
7. ListView:
• Displays a scrollable list of items.
• Uses an adapter to populate the list with data.
9. GridLayout
• An alternative to TableLayout, offering more flexibility in arranging
items in rows and columns.