EditText inheritance relationship: View --> TextView --> EditText
EditText has many attributes. Here we will introduce several attributes:
Android: hint = "enter a number! "// Set the prompt information displayed on the space
Android: numeric = "integer" // you can only enter an integer. If it is a decimal
Android: singleLine = "true" // you can specify a single-line Input. If this parameter is set to true, text is not automatically wrapped.
Android: password = "true" // you can only enter a password.
Android: textColor = "# ff8c00" // font color
Android: textStyle = "bold" // font, bold, italic, bolditalic
Android: textSize = "20dip" // size
Android: capitalize = "characters" // write with uppercase letters
Android: textAlign = "center" // EditText does not have this attribute, but TextView has and is centered.
Android: textColorHighlight = "# cccccc" // specifies the background color of the selected text. The default value is blue.
Android: textColorHint = "# ffff00" // sets the text color of the prompt message. The default color is gray. android: textScaleX = "1.5" // controls the spacing between words.
Android: typeface = "monospace" // font, normal, sans, serif, monospace
Android: background = "@ null" // background, which does not exist here. It is transparent.
Android: layout_weight = "1" // weight, controls the status between controls, and is quite useful when the control is displayed.
Android: textAppearance = "? Android: attr/textAppearanceLargeInverse "// text appearance
Android: layout_gravity = "center_vertical" // you can specify the display position of the control: top by default. bottom is displayed in the center.
Android: gray = "top" // the pointer is at the first position of the first row in multiple rows
Et. setSelection (et. length (); // adjust the cursor to the last row
Android: autoText // help for automatic spelling
Android: capitalize // uppercase
Android: digits // set to only accept certain numbers
Android: singleLine // whether a single line or multiple lines are supported. Press enter to leave the text box or Add a new line in the text box.
Android: numeric // only accept numbers
Android: phoneNumber // enter the phone number
Android: editable // whether to edit
Android: autoLink = "all" // sets the text hyperlink style. When a URL is clicked, it jumps to the URL.
Android: textAppearance = "? Android: attr/textAppearanceLargeInverse "// text appearance. Here, it refers to a built-in appearance of the system ,? Indicates whether the system has this appearance. Otherwise, the default appearance is used. I don't know, do you?
Attribute Name Description
Android: autoLink: determines whether the text is displayed as a clickable link when the text is URL link, email, phone number, or map. Optional values (none/web/email/phone/map/all)
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. There is no effect here. The input method needs to be popped up to see it. For details, see EditView this attribute description.
Android: cursorVisible: sets the cursor to show/hide, which is displayed by default.
Android: digits specifies the characters that can be entered. For example, "1234567890. +-*/% ()"
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: sets whether the editable can be edited. No effect. For more information, see EditView.
Android: editorExtras sets 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. Set the following values: "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 in the form of a marquee (horizontal animation Movement)
Android: freezesText sets 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: Text prompt information displayed when hintText 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, set the IME action in the lower-right corner to the action related to the edit box. For example, the lower-right corner of actionDone will display a "finish", without setting a carriage return symbol by default. This is described in detail in EditView, Which is useless here.
Android: imeActionId sets the IME action ID. Let's explain it again in EditView. You can read this post first: Here.
Android: imeActionLabel: sets the IME action label. In EditView, describe it again.
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 and requires a fully qualified name (complete package name ). For example, com. google. android. inputmethod. pinyin, but the error cannot be found.
Android: inputType sets the text type to help the input method display the appropriate keyboard type. Detailed description in EditView, no effect here.
Android: linksClickable sets whether the link is connected even if autoLink is set.
Android: marqueeRepeatLimit: When ellipsize specifies marquee, it sets the number of repeated scrolling times. When it is set to marquee_forever, it indicates unlimited times.
Android: EMS sets the TextView width to N characters. The test here is a Chinese character width,
Android: maxEms sets the TextView width to a maximum of N characters. Overwrite the EMS option when used with EMS.
Android: minEms sets the TextView width to a minimum of N characters. Overwrite the EMS option when used with EMS.
Android: maxLength limits the length of the displayed text. The excess part is not displayed.
Android: lines sets the number of lines of 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. It 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.
Android: lineSpacingMultiplier. For example, "1.2"
Android: If numeric is 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 EdtiView.
Android: the password is displayed as a small dot ".".
Android: Set phoneNumber to the phone number input method.
Android: privateImeOptions: it is useless to set the input method options. It will be further discussed in EditText.
Android: scrollHorizontally: Specifies whether to display strip if 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. After being set in TextView, there is no effect.
Android: shadowColor specifies the color of text shadow, which must be used with shadowRadius. Effect:
Android: shadowDx sets the start position of the horizontal shadow coordinate.
Android: shadowDy sets the start position of the Shadow vertical coordinate.
Android: shadowRadius: Set the shadowRadius. If it is set to 0.1, it becomes the font color. Generally, it is better to set it to 3.0.
Android: singleLine sets 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 displays "t ...". If singleLine is not set or is set to false, the text will wrap automatically.
Android: shadowDx sets the start position of the horizontal shadow coordinate.
Android: shadowDy sets the start position of the Shadow vertical coordinate.
Android: shadowRadius: Set the shadowRadius. If it is set to 0.1, it becomes the font color. Generally, it is better to set it to 3.0.
Android: singleLine sets 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 displays "t ...". If singleLine is not set or is set to false, the text will wrap automatically.
Android: text sets the display text.
Android: textSize: Specifies the text size. The recommended measurement unit is "sp", for example, "15sp"
Android: textStyle [bold (bold) 0, italic (italic) 1, bolditalic (bold and oblique) 2] can be set to one or more, separated by "|"
Android: typeface text font, which 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)/dp/sp/in/mm (millimeters)
Android: maxHeight sets the maximum height of the text area
Android: minHeight: sets the minimum height of the text area.
Android: width: Set the width of the text area. The measurement unit is px (pixel)/dp/sp/in/mm (mm). The difference between the measurement unit and 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.
Android: textAppearance. Such as "? Android: attr/textAppearanceLargeInverse
"Here is a built-in system appearance ,? Indicates whether the system has this appearance. Otherwise, the default appearance is used. Configurable values: textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse/textAppearanceMedium/combine/textAppearanceSmall/textAppearanceSmallInverse
Android: textAppearance. Such as "? Android: attr/textAppearanceLargeInverse
"Here is a built-in system appearance ,? Indicates whether the system has this appearance. Otherwise, the default appearance is used. Configurable values: textAppearanceButton/textAppearanceInverse/textAppearanceLarge/textAppearanceLargeInverse