

The android:textColor and android:textColorLink attribute values are hexadecimal RGB values with an optional alpha channel, similar to what's found in CSS: There is a known issue with ellipsize and multi-line text, see this MultiplelineEllipsizeTextView library for an alternative.

bccc, end for aaab., middle for aa.cc, and marquee for aaabbbccc sliding from left to right.

In addition, we can use android:ellipsize to begin truncating text įollowing values are available for ellipsize: start for. First, to restrict the total number of lines of text we can use android:maxLines and android:minLines: There are a few ways to truncate text within a TextView. Refer to this typography styles guide for more details. The basic set of styles are based on a typographic scale of 12, 14, 16, 20, and 34. Too many type sizes and styles at once can wreck any layout. It is generally a good practice to use the sp unit so the size can scale depending on user settings. Its value must consist of two parts: a floating-point number followed by a unit. Īndroid:textSize specifies the font size. The possible values are: normal, bold, italic. The android:textStyle attribute can be used to put emphasis on the text. In addition to the above, there is another attribute value named "normal" which defaults to the sans typeface. You can specify any one of them as the value for the android:typeface attribute in the XML: Text Attributes TypefaceĪs stated in the overview, there are three different default typefaces which are known as the Droid family of fonts: sans, monospace and serif. This guide will take a look at the TextView and discuss common properties associated with this view as well as how to setup custom typefaces.

You might, however, see the need to use custom fonts for special purposes. They were designed to be optimal for mobile displays, so these are the three fonts you will be working with most of the time and they can be styled using a handful of XML attributes. Every Android device comes with a collection of standard fonts: Droid Sans, Droid Sans Mono and Droid Serif.
