TextView in Android

Android provide one powerful widget to display some text on screen. Using TextView we can do this thing. TexView is basic requirement of any UI. Its works like label and have lots of useful property.

You can also create TextView pro grammatically, but right now we just see how TextView works in Android. Let’s see some useful property right now.

  • android:id : A unique resource ID for view.
  • android:text : To display our text on Textview.
  • android:textSize : To set text size. Text size is in sp(unit).
  • android:textColor : To set color of text. Its in #RGB and #ARGB formate. E.g. for black color #000000 .
  • android:textStyle : Simple style for text. Like italic, bold, normal .
  • android:lines : Makes the TextView be exactly this many lines tall..
  • android:maxLines : Makes the TextView be at most this many lines tall.
  • android:background : Background for TextView. It should be color or any image.
  • android:typeface : To set typeface of textview. Using this attribute you can change some built in fonts. But programmatically you can change it.
  • android:ellipsize : If our text is long than TextView width then its ellipsized. Like three dots at end.

This is a basic attribute of Textview to start our development. Get more information from Developer site.

Lets see one simple Example. Go to you xml file and write this code.

Our Java Code MainActivity.java

Now run Project. Our output looks like this..!


Download Project.


Now see next Tutorial EditText in Android.

(Visited 496 times, 1 visits today)