Android APITextView is the content to be introduced in this document.Android APIThe content of this document.Android APIFor more information about this document, see this article.
Like the gadgets in a mechanical City game, every widget is a useful tool in our hands. Due to time issues, we can learn its basic usage for the moment, however, you only need to learn it from the system at a time. At least you need to know that there is such an attribute and there is such a method, so that you can play a key role in some problems. Only by fully understanding it can you use it freely.
Android APIIn TextView
1. Structure
Java. lang. Object android. view. View android. widget. TextView
Direct subclass:
- Button, CheckedTextView, Chronometer, DigitalClock, EditText
Indirect subclass:
- AutoCompleteTextView, CheckBox, CompoundButton, ExtractEditText,MultiAutoCompleteTextView, RadioButton, ToggleButton
2. Android API
Attribute Name Description
Android: autoLink: sets whether to display the text as a clickable link when the text is URL-linked email phone number map. Optional value (nonewebemailphonemapall)
Android: autoText: If set, the spelling of the input value is automatically corrected. There is no effect here. It works when the input method is displayed and entered.
Android: bufferType: Specifies the text category obtained by getText. The editable option is similar to the append character of StringBuilder. That is to say, after getText, you can use the append method to set the text content. Spannable can use styles in a given character area. For more information, see 1. 2.
Android: capitalize: Set uppercase letters. There is no effect here. You need to pop up the input method to see it. For more information, see EditText.
Android: cursorVisible: sets the cursor to show and hide, which is displayed by default.
Android: digits: Specifies the characters that can be entered. For example, "1234567890. +-* % \ n ()"
Android: drawableBottom: outputs a drawable under text. If a color is specified, the background of the text is set to this color, and the latter is overwritten with the background.
Android: drawableLeft: outputs a drawable on the left of text.
Android: drawablePadding: sets the interval between text and drawable (image). It can be used with drawableLeft, drawableRight, drawableTop, and drawableBottom. It can be set to a negative number, but it has no effect.
Android: drawableRight: outputs a drawable on the Right of text.
Android: drawableTop: outputs a drawable on the top of the text.
Android: editable: sets whether to edit. No effect. For more information, see EditView.
Android: editorExtras: set additional text input data. We will discuss it again in EditView.
Android: ellipsize: Set how to display the control when the text is too long. The following settings are available:
"Start" -- The ellipsis is displayed at the beginning;
"End" -- The ellipsis is displayed at the end;
"Middle" -- The ellipsis is displayed in the middle;
"Marquee"-displayed as a marquee (horizontal movement of the animation)
Android: freezesText: Set the content of the saved text and the position of the cursor. See: Here.
Android: gravity: sets the text position. For example, if it is set to "center", the text is displayed in the center.
Android: hint: Text prompt information displayed when the Text is empty. You can use textColorHint to set the color of the prompt information. This attribute is used in EditView, but it can also be used here.
Android: imeOptions: additional function. It sets the IME action and the action related to the edit box in the lower right corner. For example, a "finish" is displayed in the lower right corner of actionDone, without setting a carriage return symbol by default. This is described in detail in EditText, Which is useless here.
Android: imeActionId: sets the IME action ID. Let's explain it again in EditText. You can read this post first: Here.
Android: imeActionLabel: sets the IME action label. Describe it in EditText.
Android: includeFontPadding: sets whether the text contains additional white space at the top and bottom. The default value is true.
Android: inputMethod: Specifies the Input Method for text. You must specify the full package name ). For example, com. google. android. inputmethod. pinyin, but the error cannot be found.
Android: inputType: Set the text type to help the input method display the appropriate keyboard type. It is described in detail in EditText, and there is no effect here. Android: linksClickable: sets whether the link is connected even if autoLink is set.
Android: marqueeRepeatLimit: When marquee is specified in ellipsize, the number of repeated scrolling times is set. When marquee_forever is set, the number of times is unlimited.
Android: EMS: Set the TextView width to N characters. The test here is a Chinese character width,
Android: maxEms: Set the TextView width to a maximum of N characters. Overwrite the EMS option when used with EMS.
Android: minEms: Set the TextView width to the width of a minimum of N characters. Overwrite the EMS option when used with EMS.
Android: maxLength: restrict the length of the displayed text. The excess part is not displayed.
Android: lines: sets the number of lines in the text. If two lines are set, two lines are displayed, even if the second row has no data.
Android: maxLines: sets the maximum number of lines displayed in text. This parameter is used in combination with width or layout_width. If the line exceeded is automatically wrapped, the line exceeded is not displayed.
Android: minLines: sets the minimum number of lines of text, similar to lines
Android: lineSpacingExtra: Set the line spacing.
Android: lineSpacingMultiplier: Set the line spacing multiple. For example, "1.2"
Android: numeric: If set, the TextView has a digital input method. This is useless. The only effect after setting is that TextView has a click effect. This attribute is described in detail in EditText.
Android: password: show text in a small dot "."
Android: phoneNumber: Enter the phone number.
Android: privateImeOptions: it is useless to set the input method options. It will be further discussed in EditText.
Android: scrollHorizontally: sets whether to display a horizontal bar when the text exceeds the TextView width.
Android: selectAllOnFocus: if the text is selectable, let him get the focus instead of moving the cursor to the start or end of the text. It is ineffective after being set in EditText.
Android: shadowColor: Specifies the color of text shadow, which must be used with shadowRadius. Effect:
Android: shadowDx: sets the start position of the Shadow horizontal coordinate.
Android: shadowDy: Set the start position of the Shadow vertical coordinate.
Android: shadowRadius: Set the shadow radius. If it is set to 0.1, it becomes the font color. Generally, it is better to set it to 3.0.
Android: singleLine: Set single row display. If it is used with layout_width, when the text cannot be fully displayed, "…" is used later. .
For example
- Android: text = "test _ singleLine"
- Android: singleLine = "true"
- Android: layout_width = "20dp" only "t…" is displayed ...". If singleLine is not set or is set to false, the text will wrap automatically.
Android: text: Set display text
Android: textAppearance: Set the text appearance. Such as "? Android: attrtextAppearanceLargeInverse
"Here is a built-in system appearance ,? Indicates whether the system has this appearance. Otherwise, the default appearance is used. The configurable values are as follows:
- textAppearanceButton
- textAppearanceInverse
- textAppearanceLarge
- textAppearanceLargeInverse
- textAppearanceMedium
- textAppearanceMediumInverse
- textAppearanceSmall
- textAppearanceSmallInverse
Android: textColor: set text color
Android: textColorHighlight: the background color of the selected text. The default value is blue.
Android: textColorHint: Set the color of the text in the prompt message. The default value is gray. Used with hint.
Android: textColorLink: text link color.
Android: textScaleX: Set the interval between texts. The default value is 1.0f. Set 0.5f1.0f1.5f2.0f as follows:
Android: textSize: Set the text size. The recommended measurement unit is "sp", for example, "15sp"
Android: textStyle: Set the font [bold (bold) 0, italic (italic) 1, bolditalic (bold and oblique) 2] You can set one or more, separated by "|"
Android: typeface: Set the text font. It must be one of the following constant values: normal 0, sans 1, serif 2, monospace (same width font) 3]
Android: height: sets the height of the text area. supported measurement units: px (pixels) dpspinmm (millimeters)
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. The unit of measurement is px (pixel) dpspinmm (mm). The difference from layout_width is shown here.
Android: maxWidth: sets the maximum width of the text area.
Android: minWidth: sets the minimum width of the text area.
Summary:Android APIThe content of TextView in the Chinese document is described.Android APIContent learning is helpful to you!