Cодержание
Руководство Android TextView
View more Tutorials:


В Android, TextView это контроль пользовательского интерфейса (User Interface Control), который используется для отображения текста, он работает как метка (Label), по умолчанию пользователь не может редактировать содержание текста.

Attribute | Description |
---|---|
android:id | It is used to uniquely identify the control |
android:autoLink | It will automatically found and convert URL(s) and email addresses as clickable links. |
android:ems | It is used to make the TextView be exactly this many ems wide. |
android:hint | It is used to display the hint text when text is empty |
android:width | It makes the TextView be exactly this many pixels wide. |
android:height | It makes the TextView be exactly this many pixels tall. |
android:text | It is used to display the text. |
android:textColor | It is used to change the color of the text. |
android:gravity | It is used to specify how to align the text by the view's x and y-axis. |
android:maxWidth | It is used to make the TextView be at most this many pixels wide. |
android:minWidth | It is used to make the TextView be at least this many pixels wide. |
android:textSize | It is used to specify the size of the text. |
android:textStyle | It is used to change the style (bold, italic, bolditalic) of text. |
android:textAllCaps | It is used to present the text in all CAPS. |
android:typeface | It is used to specify the Typeface (normal, sans, serif, monospace) for the text. |
android:textColorHighlight | It is used to change the color of text selection highlight. |
android:textColorLink | It is used to change the text color of links. |
android:inputType | It is used to specify the type of text being placed in text fields. |
android:fontFamily | It is used to specify the fontFamily for the text. |
android:editable | If we set, it specifies that this TextView has an input method. |
android:autoLink
Данный атрибут говорит Android автоматически создать ссылки (link) для номеров телефона, адресов, электронной почты, адрес вебсайтов, найденных в тексте TextView.

Constant | Value | Description |
all | f | Match all patterns (equivalent to web|email|phone|map). |
2 | Match email addresses. | |
map | 8 | Match map addresses. |
none | 0 | Match no patterns (default). |
phone | 4 | Match phone numbers. |
web | 1 | Match Web URLs |
<TextView
android:id="@+id/textView_a11"
android:autoLink="email|phone|map|web"
android:textColorLink="#FF0000"
android:text="Contact: +1-1111222233, example@gmail.com. http://abc.com, 620 Eighth Avenue New York, NY 10018"
... />

Click on Phone Link.

Click on Email Link

Click on Web URL

Click on Address Link (Will open Google Map)
android:ems
Данный атрибут используется для определения значения ширины TextView в единицах измерения EM. При этом EM это единица измерения в Typography (Типография), его значением является ширина буквы "M".
Таким образом android:ems="5" - значит настроить ширину для TextView в 5 раз больше ширины буквы "M".
android:text
Определить содержание текста для TextView.
android:textColor
Настроить цвет текста для TextView.

android:textSize
Настроить размер шрифта текста.

android:textStyle
Настроить стиль шрифту, данный атрибут имеет 4 значения:
- android:textStyle="normal" (Default)
- android:textStyle="bold"
- android:textStyle="italic"
- android:textStyle="bold|italic"

android:textAllCaps
Данный атрибут имеет 2 значения true/false. Со значением true, текст TextView превратится в прописные буквы при отображении. Значение по умолчанию это false.
android:textColorHighlight
Настроить цвет фона для выбранных под-текстов. Данный атрибут удобен, когда вы используете EditText (Подкласс у TextView). EditText позволят пользователю выбрать и изменять его текст.

android:textColorLink
Настроить цвет текста для ссылок (link) в тексте. (Смотрите больше про android:autoLink).

android:fontFamily
Настроить font family (Семейство шрифтов) для TextView.

android:editable