Overview TextView
A TextView ui element allows to display text.
xml attributes
attribute | description |
---|---|
autoLink | Controls whether links such as urls and email addresses are automatically found and converted to clickable links. |
maxLines | Specifies how many lines the TextView may have. |
lines | Makes the TextView be exactly this many lines tall. |
text | Text to display. |
drawableXXX | Properties to configure icons of TextView. Icons can be displayed at start and end of text, also above or below of text (drawableTop/drawableBottom). |
clickable link
LinkMovementMethod class allows you to add clickable links in text.
rootView.findViewById<AppCompatTextView>(R.id.txtContent)?.apply {
setMovementMethod(LinkMovementMethod.getInstance())
setLinkTextColor(Color.BLUE)
}
String can contain any supported schemes like http, tel, etc.
<string name="home_article_contact_marking_operator">
<![CDATA[contact phone: <a href="tel:+998-78-000-00-00">+998-78-000-00-00</a>.]]>
</string>