Android for Beginners
About Lesson

In Android, User Interface (UI) controls are used to create interactive user interfaces. They are the building blocks of the user interface and include elements like buttons, text fields, checkboxes, etc. Let’s explore some commonly used UI controls in Android.

TextView

TextView is a UI control that displays text to the user. It’s used for labels, descriptions, and any other text elements.

<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, World!" />



EditText

An EditText is a user-editable text field. It’s used for text input fields such as search boxes, login fields, etc.

<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

 

 

Button

Button is a clickable element that acts when the user taps on it.

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me" />

 

 

CheckBox

CheckBox is a two-state button that can be either checked or unchecked.

<CheckBox
android:id="@+id/check_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Check Me" />

 

 

RadioButton

RadioButton is a two-state button that can be either checked or unchecked. However, unlike a CheckBox, a set of RadioButtons are grouped, and only one RadioButton in a group can be checked at a time.

<RadioGroup
android:id="@+id/radio_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<RadioButton
android:id="@+id/radio_button_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 1" />

<RadioButton
android:id="@+id/radio_button_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 2" />

</RadioGroup>

 

 

Spinner

Spinner provides a quick way to select one value from a set. In the default state, a spinner shows its currently selected value.

<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />


 

ProgressBar

ProgressBar is a visual indicator of progress in some operations. Displays a bar to the user representing how far the operation has progressed.

<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

 

 

SeekBar

SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level.

<SeekBar
android:id="@+id/seek_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />