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

Unit2 UsingViews

The document provides an overview of designing user interfaces in Android using various types of views, including basic views like TextView, EditText, and Button, as well as picker and list views. It explains the functionality of these views and their implementation in XML layout files. Additionally, it highlights the importance of using the appropriate view types for user interaction and content display.

Uploaded by

darshan859900
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)
2 views9 pages

Unit2 UsingViews

The document provides an overview of designing user interfaces in Android using various types of views, including basic views like TextView, EditText, and Button, as well as picker and list views. It explains the functionality of these views and their implementation in XML layout files. Additionally, it highlights the importance of using the appropriate view types for user interaction and content display.

Uploaded by

darshan859900
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

Designing User Interface with Views

Views
View is the basic building block of UI(User Interface) in android. View refers to the
[Link] 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 [Link],
[Link] 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="[Link]
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