SoFunction
Updated on 2025-03-01

Detailed introduction to android TextView properties Share

android:autoLink sets whether the text is a URL link/email/phone number/map, the text is displayed as a clickable link. Optional value (none/web/email/phone/map/all)
android:autoText If set, spelling correction of the input value will be performed automatically. There is no effect here, and it works when displaying the input method and inputting.
android:bufferType specifies the text category obtained by getText() method. The editable option is similar to StringBuilder to append characters, which means that after getText, you can call the append method to set the text content. spannable can use styles in a given character area, see here 1 and here 2.
android:capitalize sets the capitalization type of English letters. There is no effect here, and you need to pop up the input method to see it. See EditView's property description.
android:cursorVisible sets the cursor to show/hide, and displays by default.
android:digits sets which characters are allowed to be entered. Such as "1234567890.+-*/% ()"
android:drawableBottom outputs a drawable below the text, as shown in the picture. If a color is specified, the background of the text will be set to that color, and the latter will be overwritten when used in background.
android:drawableLeft outputs a drawable on the left side of the text, as shown in the picture.
android:drawablePadding sets the interval between text and drawable (picture), and is used with drawableLeft, drawableRight, drawableTop, drawableBottom. It can be set to a negative number, and it has no effect when used alone.
android:drawableRight outputs a drawable on the right side of the text.
android:drawableTop outputs a drawable directly above the text.
android:editable setting is editable.
android:editorExtras sets additional input data for text.
android:ellipsize sets how the control should be displayed when the text is too long. There are the following value settings: "start"—?ellipsis is displayed at the beginning; "end"—ellipsis is displayed at the end; "middle"—ellipsis is displayed in the middle; "marquee"—that is displayed in the form of a marquee (animation moves horizontally)
android:freezesText sets the content of the text and the position of the cursor.
android:gravity sets the text position. If set to "center", the text will be displayed in the center.
The text prompt information displayed when android:hintText is empty can be set through textColorHint. This property is used in EditView, but it can also be used here.
Android:imeOptions additional function, sets the IME action in the lower right corner and the edit box related actions. For example, the lower right corner of actionDone will display a "complete" without setting a default entry symbol. This is explained in detail in EditView, and it is useless here.
android:imeActionId sets the IME action ID.
android:imeActionLabel sets the IME action tag.
android:includeFontPadding sets whether the text contains extra white space at the top and bottom, defaults to true.
android:inputMethod specifies input method for text, and requires a fully qualified name (full package name). For example:, but an error is reported here and cannot be found.
android:inputType sets the type of text to help the input method display the appropriate keyboard type. It will be explained in detail in EditView, but there is no effect here.
android:linksClickable Set whether the link clicks on the connection, even if autoLink is set.
android:marqueeRepeatLimit When ellipsize specifies marquee, sets the number of times repeated scrolling, and indicates infinite times when set to marquee_forever.
android:ems sets the width of the TextView to the width of N characters. Here is a Chinese character width
android:maxEms Set the width of the TextView to the width of the longest N characters. Override the ems option when used with ems.
android:minEms Set the width of the TextView to the shortest width of N characters. Override the ems option when used with ems.
android:maxLength limits the displayed text length, and the excess part will not be displayed.
android:lines sets the number of lines of text. Setting two lines will show two lines, even if the second line has no data.
android:maxLines sets the maximum number of lines displayed in text, used in combination with width or layout_width, if the excess line wraps, the number of lines will not be displayed.
android:minLines sets the minimum number of lines of text, similar to lines.
android:lineSpacingExtra sets the line spacing.
android:lineSpacingMultiplier sets multiples of line spacing. Such as "1.2"
android:numeric If set, the TextView has a numeric input method. This is useless. The only effect after setting is that the TextView has a click effect. This property will be explained in detail in EdtiView.
android:password displays text with small dots "."
android:phoneNumber is set as the input method of the phone number.
android:privateImeOptions set input method options, which is useless here, and will be discussed further in EditText.
android:scrollHorizontally sets whether horizontal pull bars appear when the text exceeds the width of the TextView.
android:selectAllOnFocus If the text is selectable, let it get the focus instead of moving the cursor to the beginning or end position of the text. There is no effect after setting in TextView.
android:shadowColor specifies the color of the text shadow, which needs to be used with shadowRadius.
android:shadowDx sets the start position of the shadow horizontal coordinate.
android:shadowDy sets the start position of the shadow portrait coordinates.
android:shadowRadius sets the radius of the shadow. Set to 0.1 to become the font color, and generally the effect is better if set to 3.0.
android:singleLine sets a single line display. If used with layout_width, when the text cannot be displayed all, it will be represented by "..." later. For example android:text="test_ singleLine"
android:singleLine="true" android:layout_width="20dp" will only display "t...". If singleLine is not set or false, the text will be automatically wrapped
android:text settings to display text.
android:textAppearance sets the text appearance. For example, "?android:attr/textAppearanceLargeInverse" refers to a appearance that comes with the system, indicating whether the system has this appearance, otherwise the default appearance will be used. The values ​​that can be set are as follows: textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse/textAppearanceMedium/textAppearanceMediumInverse/textAppearanceSmall/textAppearanceSmallInverse
android:textColor set text color
android:textColorHighlight is selected for the background color of the text, default to blue
android:textColorHint sets the color of the prompt message text, default to gray. Use with hint.
android:textColorLink text link color.
android:textScaleX sets the interval between texts, default is 1.0f.
android:textSize sets the text size, and recommends the unit of measurement "sp", such as "15sp"
android:textStyle Set glyph [bold (bold) 0, italic (italic) 1, bolditalic (bold and oblique) 2] You can set one or more, separated by "|"
android:typeface sets text font, which must be one of the following constant values: normal 0, sans 1, serif 2, monospace (monospace font) 3]
android:height sets the height of the text area, supports measurement units: px (pixels)/dp/sp/in/mm (mm)
android:maxHeight sets the maximum height of the text area
android:minHeight sets the minimum height of the text area
android:width sets the width of the text area, and supports unit of measurement: px (pixels)/dp/sp/in/mm (mm). The difference between layout_width is here.
android:maxWidth sets the maximum width of the text area
android:minWidth sets the minimum width of the text area