From wiki.ginstr.com
Revision as of 14:39, 24 June 2016 by Mark (talk | contribs) (Using HTML markup in text)
Jump to: navigation, search

This is the standard Android Widgetbut it's outlined here because of its text display capabilities.TextView's purpose is primarily to display text but can also be used to contain links.

Widget XML tag
<TextView>

XML Attributes Description

Attribute Description
#android:autoLink Enables the linking of text to open web browser URLs, email client, etc.
#android:text Displays desired text in the TextView.

Using HTML markup in text

When writing text within TextView or GnTextView the designer has the option to use HTML language to style the text displayed. A few tags will be elaborated on.

XML characters < and > are reserved for XML only. This means you need to write alternative symbols which represent them where < is &lt; and > is &gt;

The following text demonstrates how to use alternative symbols.

Character is also a reserved character and needs to be written as \“.

HTML mark-up tags:

&lt;BR/&gt; (<BR/>)
breaks line into a new row
&lt;a href=\”mailto:email@ginstr.com\”&gt;EMAIL&lt;/a&gt; (<a href=”mailto:email@ginstr.com”>EMAIL</a>)
creates an email link on the text EMAIL which is displayed in TextView. Clicking on it displays the menu for choosing an email program.
&lt;font color="#46b4e7"&gt;other color text&lt;/font&gt; (<<font color=”#46b4e7”>other color text</font>)
text that is within these tags will be a different color

Tags can also be nested and there are many more that can be used. Refer to Android Documentation for more details on HTML and tags.

android:autoLink

Enables the linking of text to open web browser URLs, email client, etc. Each link opens different intent

(String) values = none, web, email, phone, map, all

Value Description
none Matches no pattern
web Recognises web addresses and converts them to links
email Recognises web addresses and converts them to links
phone Recognises phone numbers and converts them to links
map Recognises map addresses and converts them to links

android:text

Displays desired text in the TextView. It is possible to use HTML tags to format text.