0% found this document useful (0 votes)
3 views9 pages

Unit2_UsingViews

The document provides an overview of user interface design in Android, focusing on the View class as the fundamental component for UI elements like TextView, Button, and ImageView. It categorizes views into basic views, picker views, list views, and specialized fragments, detailing their functions and usage. Additionally, it includes examples of XML layout for implementing basic views in an Android project.

Uploaded by

devangverma2025
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views9 pages

Unit2_UsingViews

The document provides an overview of user interface design in Android, focusing on the View class as the fundamental component for UI elements like TextView, Button, and ImageView. It categorizes views into basic views, picker views, list views, and specialized fragments, detailing their functions and usage. Additionally, it includes examples of XML layout for implementing basic views in an Android project.

Uploaded by

devangverma2025
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Designing User Interface with Views

Views
View is the basic building block of UI(User Interface) in android. View refers to the
android.view.View class, which is the super class for all the GUI components like
TextView, ImageView, Button etc.
 Basic views—Commonly used views, such as the TextView, EditText, and Button
views.
 Picker views—Views that enable users to select from a list, such as the TimePicker
and DatePicker views.
 List views—Views that display a long list of items, such as the ListView and the
SpinnerView views.
 Specialized fragments—Special fragments that perform specific functions.

1
Designing User Interface with Views

Using Basic Views


 Textview
 EditText
 Button
 ImageButton
 CheckBox
 ToggleButton
 RadioButton
 RadioGroup

2
Designing User Interface with Views

Using Basic Views

3
Designing User Interface with Views

Using Basic Views


 These basic views enable you to display text information, as well as perform some
basic selection.
 View class extends Object class and implements Drawable.Callback,
KeyEvent.Callback and AccessibilityEventSource.
 match_parent will occupy the complete space available on the display of the
device. Whereas, wrap_content will occupy only the space required for the content
to display.
TextView
 Example of Textview,
 When a new Android project is created, activity_main.xml file (located in the
res/layout folder), contains a <TextView> element:

4
Designing User Interface with Views

TextView
<?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:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>

5
Designing User Interface with Views

TextView
TextView view is used to display text to the user. This is the most basic view and one
that you will frequently use when you develop Android applications. If you need to
allow users to edit the text displayed, you should use the subclass of TextView—
EditText.

Button, ImageButton, EditText, CheckBox, ToggleButton, RadioButton and


RadioGroup Views
Besides the TextView view, there are other basic views that we would be using
frequently:
• Button - Represents a push-button widget.
• ImageButton - Similar to the Button view, except that it also displays an
image.
6
• EditText -A subclass of the TextView view, which allows users to edit its text
Designing User Interface with Views

Button, ImageButton, EditText, CheckBox, ToggleButton, RadioButton and


RadioGroup Views
• A RadioGroup is used to group one or more RadioButton views, thereby
allowing only one RadioButton to be checked within the RadioGroup.
• ToggleButton—Displays checked/unchecked states using a light indicator.

• Using Android Studio, create an Android project and name it BasicViews1.


• Modify the activity_main.xml file located in the res/layout folder by adding the
following elements shown in bold:

7
Designing User Interface with Views

Button, ImageButton, EditText, CheckBox, ToggleButton, RadioButton and


RadioGroup Views
• A RadioGroup is used to group one or more RadioButton views, thereby
allowing only one RadioButton to be checked within the RadioGroup.
• ToggleButton—Displays checked/unchecked states using a light indicator.

• Using Android Studio, create an Android project and name it BasicViews1.


• Modify the activity_main.xml file located in the res/layout folder by adding the
following elements shown in bold:

8
Designing User Interface with Views

Button, ImageButton, EditText, CheckBox, ToggleButton, RadioButton and


RadioGroup Views

You might also like