Professional Documents
Culture Documents
4 Unit Mad
4 Unit Mad
Designing User
Interfaces with View
1.1Text View
• In Android, TextView displays text to the user and
optionally allows them to edit it programmatically.
• TextView is a complete text editor, however basic class is
configured to not allow editing but we can edit it.
• View is the parent class of TextView.
• Being a subclass of view the text view component can be
used in your app’s GUI inside a ViewGroup, or as the
content view of an activity.
• We can create a TextView instance by declaring it inside a
layout(XML file) or by instantiating it programmatically(Java
Class).
Attributes of TextView:
1 android:completionHint
This defines the hint displayed in the drop down menu.
android:completionHintView
2 This defines the hint view displayed in the drop down
menu.
android:completionThreshold
3 This defines the number of characters that the user
must type before completion suggestions are displayed
in a drop down menu.
android:dropDownAnchor
4 This is the View to anchor the auto-complete dropdown
to.
5 android:dropDownHeight
This specifies the basic height of the dropdown.
android:dropDownHorizontalOffset
6 The amount of pixels by which the drop down
should be offset horizontally.
7 android:dropDownSelector
This is the selector in a drop down list.
android:dropDownVerticalOffset
8 The amount of pixels by which the drop down
should be offset vertically.
android:dropDownWidth
9 This specifies the basic width of the
dropdown.
10 android:popupBackground
This sets the background.
2.1 Button
• In Android, Button represents a push button. A Push buttons can be
clicked, or pressed by the user to perform an action. There are
different types of buttons us in android such as CompoundButton,
ToggleButton, RadioButton.
• Button is a subclass of TextView class and compound button is the
subclass of Button class. On a button we can perform different
actions or events like click event, pressed event, touch event etc.
• Android buttons are GUI components which are sensible to taps
(clicks) by the user. When the user taps/clicks on button in an
Android app, the app can respond to the click/tap. These buttons
can be divided into two categories: the first is Buttons with text on,
and second is buttons with an image on. A button with images on
can contain both an image and a text. Android buttons with images
on are also called ImageButton.
Attributes of Button in Android:
android:autoText
If set, specifies that this TextView
1 has a textual input method and
automatically corrects some
common spelling errors.
android:drawableBottom
2 This is the drawable to be drawn
below the text.
android:drawableRight
3 This is the drawable to be drawn
to the right of the text.
android:editable
4 If set, specifies that this TextView
has an input method.
5 android:text
This is the Text to display.
Inherited from android.view.View Class −
Attribute Description
1 android:background
This is a drawable to use as the background.
android:contentDescription
2 This defines text that briefly describes content of the
view.
3 android:id
This supplies an identifier name for this view.
android:onClick
4 This is the name of the method in this View's context to
invoke when the view is clicked.
5 android:visibility
This controls the initial visibility of the view.
2.2 ImageButton
android:adjustViewBounds
1 Set this to true if you want the ImageView to adjust its bounds to
preserve the aspect ratio of its drawable.
2 android:baseline
This is the offset of the baseline within this view.
android:baselineAlignBottom
3 If true, the image view will be baseline aligned with based on its bottom
edge.
4 android:cropToPadding
If true, the image will be cropped to fit within its padding.
5 android:src
This sets a drawable as the content of this ImageView.
Inherited from android.view.View Class −
1 android:background
This is a drawable to use as the background.
2 android:contentDescription
This defines text that briefly describes content of the view.
3 android:id
This supplies an identifier name for this view
android:onClick
4 This is the name of the method in this View's context to invoke
when the view is clicked.
5 android:visibility
This controls the initial visibility of the view.
ToggleButton (On/Off)
android:disabledAlpha
1 This is the alpha to apply to the indicator
when disabled.
android:textOff
2 This is the text for the button when it is not
checked.
android:textOn
3 This is the text for the button when it is
checked.
Inherited from android.widget.TextView Class
android:autoText
1 If set, specifies that this TextView has a textual input method and
automatically corrects some common spelling errors.
2 android:drawableBottom
This is the drawable to be drawn below the text.
3 android:drawableRight
This is the drawable to be drawn to the right of the text.
4 android:editable
If set, specifies that this TextView has an input method.
5 android:text
This is the Text to display.
RadioButton & RadioGroup
1 android:background
This is a drawable to use as the background.
2 android:contentDescription
This defines text that briefly describes content of the view.
3 android:id
This supplies an identifier name for this view
android:onClick
4 This is the name of the method in this View's context to invoke when
the view is clicked.
5 android:visibility
This controls the initial visibility of the view.
Check Box
• In Android, CheckBox is a type of two state button either
unchecked or checked in Android. Or you can say it is a type
of on/off switch that can be toggled by the users.
• You should use checkbox when presenting a group of selectable
options to users that are not mutually exclusive.
• Compound Button is the parent class of CheckBox class.
• In android there is a lot of usage of check box. For example, to
take survey in Android app we can list few options and allow user
to choose using Check Box.
• The user will simply checked these checkboxes rather than type
their own option in Edit Text. Another very common use of Check
Box is as remember me option in Login form.
Attribute of Check Box
Sr.No Attribute & Description
android:autoText
1 If set, specifies that this TextView has a textual input
method and automatically corrects some common spelling
errors.
2 android:drawableBottom
This is the drawable to be drawn below the text.
3 android:drawableRight
This is the drawable to be drawn to the right of the text.
4 android:editable
If set, specifies that this TextView has an input method.
5 android:text
This is the Text to display.
Android . View. View Class −
Sr.No Attribute & Description
1 android:background
This is a drawable to use as the background.
2 android:contentDescription
This defines text that briefly describes content of the view.
3 android:id
This supplies an identifier name for this view.
android:onClick
4 This is the name of the method in this View's context to invoke when
the view is clicked.
5 android:visibility
This controls the initial visibility of the view.
Progress Bar
1
getMax()
This method returns the maximum value of the progress.
2
incrementProgressBy(int diff)
This method increments the progress bar by the difference of value passed as a parameter.
3
setIndeterminate(boolean indeterminate)
This method sets the progress indicator as determinate or indeterminate.
4
setMax(int max)
This method sets the maximum value of the progress dialog.
5
setProgress(int value)
This method is used to update the progress dialog with some specific value.
6
show(Context context, CharSequence title, CharSequence message)
This is a static method, used to display progress dialog.