![]() |
VOOZH | about |
TextView in Android is one of the basic and important UI elements. This plays a very important role in the UI experience and depends on how the information is displayed to the user. This TextView widget in Android can be dynamized in various contexts. For example, if the important part of the information is to be highlighted then the substring that contains, it is to be italicized or it has to be made bold, one more scenario is where if the information in TextView contains a hyperlink that directs to a particular web URL then it has to be spanned with hyperlink and has to be underlined.
Have a look at the following list and image to get an idea of the overall discussion.
Table of Content
Step 1: Create an Empty Activity Project
Step 2: Working with the activity_main.xml file
To implement the UI of the activity invoke the following code inside the activity_main.xml file.
Output UI:
Android offers mainly 3 types of typefaces
- normal
- sans
- serif
- monospace
The above four types of faces are to be invoked under the "typeFace" attribute of the TextView in XML.
Invoke the following code and note the "typeFace" attribute of the TextView.
The attribute which is used to change the size of the Text View in android is "textSize".
Refer to the following code and its output for better understanding.
Output:
In Android there are basically three text styles:
- Bold
- Italic
- Normal
To implement the various text styles refer to the following code and its output.
Refer to the following code and its output for better understanding.
android:shadowDx="integer_value" -> which decides the distance of text from its shadow with respect to x axis, if the integer_value is positive the shadow is on positive of the x axis and vice versa.
android:shadowDy="integer_value" -> which decides the distance of text from its shadow with respect to y axis, if the integer_value is positive the shadow is on negative of the y axis and vice versa.
android:shadowRadius="integer_value" -> which decides the amount of the shadow to be given for the text view.
Refer to the following code and its output for better understanding.
android:letterSpacing="floatingTypeValue" -> This attribute is used to give the space between each of the letters.
android:textAllCaps="trueOrfalse" -> This attribute decides, all the letters should be in uppercase or not.
Refer to the following code and its output for better understanding.
activity_main.xml :
Click Here to Learn more to Create Your Own Android Kotlin App