Learn UI controls in Android in simple language

Input controls; Interactive components are in the interface of your applications. Android provides a wide variety of controls that you can use in your own UI. 

These controls include buttons, text fields, seekbars, checkboxes, zoom buttons, status shift buttons, and more.

UI Control

UI elements

A view is actually an object that manages something that the user can interact with, and a ViewGroup is an object that holds other views to determine the interface pagination.

You define your pagination in an XML file that provides a human-readable structure similar to HTML for pagination. for example; A simple vertical pagination with a text and a button similar to the following:

<? xml version = ”1.0 ″ encoding =” utf-8 ″?>

<LinearLayout xmlns: android = ”http://schemas.android.com/apk/res/android”

android: layout_width = ”fill_parent”

android: layout_height = ”fill_parent”

android: orientation = ”vertical”>

<TextView android: id = ”@ + id / text”

android: layout_width = ”wrap_content”

android: layout_height = ”wrap_content”

android: text = ”I am a TextView” />

<Button android: id = ”@ + id / button”

android: layout_width = ”wrap_content”

android: layout_height = ”wrap_content”

android: text = ”I am a Button” />

</LinearLayout>

Android UI controls

There are a number of UI controls provided by Android that allow you to create a graphical user interface for your application:

Row UI controls and their explanation
1 Text display (text view)This control is used to display a text to the user.
۲ Text editing (text editing)Text Editing is a predefined subclass of Text View that has very powerful editing capabilities.
3 AutoCompleteTextViewThis control; Is a view that is similar to text editing, except that when the user is typing; Displays a list of completion suggestions automatically.
4 buttonsA button that the user can touch or click to take action.
5

ImageButton (image button)

An image button; It is an absolute pagination that enables you to determine the exact position of the child. This control displays a button with an image (instead of text) that the user can touch or click.

6 CheckboxAn on / off switch that the user can change its status. You should use the checkbox when you want to provide users with a set of portable options that are incompatible in pairs.
7 ToggleButton status switch buttonThere is an on / off button that indicates that a light is on and off.
8 Radio Button – RadioButtonThe radio button has two modes: either checked or not.
9 RadioGroupRadiogroups are used to group several radio buttons.
10 Progress barProgress bar

On-screen progress bar; Creates a display that shows the process of performing tasks; For example, when you perform a task; Shows the process of doing it.

۱۱ SpinnerA drop-down list that allows users to get a value from a set.
۱۲ TimePickerThis view enables users to select a time of day in either the 24-hour format or the 12-hour before / afternoon format.
13 DatePickerThis view enables users to select a specific date.

Create UI controls

Input controls are interactive components in your application interface. Android provides a wide range of these controls that you can use in your own UI. These controls include buttons, text fields, seekbars, checkboxes, zoom buttons, and status buttons.

As described in the previous chapter; A View object can have a specific ID assigned to it that identifies that view exclusively within the tree. The syntax for an ID inside an XML tag is as follows:

android: id = ”@ + id / text_id”

To create a widget / control / user interface; You must define each one you want in the pagination file and assign it a unique identifier as shown below.

<? xml version = ”1.0 ″ encoding =” utf-8 ″?>

<LinearLayout xmlns: android = ”http://schemas.android.com/apk/res/android”

android: layout_width = ”fill_parent”

android: layout_height = ”fill_parent”

android: orientation = ”vertical”>

<TextView android: id = ”@ + id / text_id”

android: layout_width = ”wrap_content”

android: layout_height = ”wrap_content”

android: text = ”I am a TextView” />

</LinearLayout>

Then finally; Using the following coding, an example of the control object is created and received from the pagination:

TextView myText = (TextView) findViewById (R.id.text_id);

Leave a Reply

Your email address will not be published. Required fields are marked *