Android APIThe Chinese Document EditText is the content to be introduced in this article, mainly to understand and learnAndroid APIDocumentation help, detailsAndroid APIFor more information, see this article.
I. Structure of Android APIs
- java.lang.Object
- android.view.View
- android.widget.TextView
- android.widget.EditText
Known direct subclass:
- AutoCompleteTextView,ExtractEditText
Known indirect subclass:
- MultiAutoCompleteTextView
Ii. xml attributes in Android APIs
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 ). The link is automatically recognized only when text is set at the same time, and the link entered later cannot be automatically recognized.
Android: autoText help for automatic spelling. The setting is ineffective here, and may require assistance from other input methods. For more information about the effect, see the video.
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 the value as follows: sentences only indicates the size of the first letter of a word in uppercase; words indicates the size of the first letter of a word in uppercase. characters indicates the size of each letter in uppercase. In the simulator, you can directly enter the keyboard on the PC, but the keyboard is ineffective.
Android: cursorVisible: sets the cursor to show/hide, which is displayed by default. If it is set to false, the cursor bar is not displayed even if it is selected.
Android: digits specifies the characters that can be entered. For example, "1234567890. +-*/% \ n ()"
Android: drawableTop outputs a drawable on the top of the text. The effect in EditView is funny: it is in the text box and cannot be deleted.
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 film 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: sets whether the editable can be edited. The cursor can still be obtained, but cannot be entered.
Android: editorExtras indicates the extension of a specific input method, for example, "com. mydomain. im. SOME_FIELD ". The source code is tracked to EditorInfo. extras, and no relevant implementation code is available.
Android: ellipsize: Set how to display the control when the text is too long. You can set the following values: "start" -- ellipsis () at the beginning, "end" -- ellipsis () at the end, and "middle" -- ellipsis () in the middle; "marquee"-displayed as a marquee (horizontal movement of the animation)
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.
Android: imeOptions: Set the Enter key for the keyboard. You can set the following values: normal, actionUnspecified, actionNone, actionGo, actionSearch, actionSend, actionNext, actionDone, flagNoExtractUi, flagNoAccessoryAction, and flagNoEnterAction. You can use '|' to set multiple parameters. Only the display icon is set here. See the example at the end of the article.
Android: imeActionId: Set the IME action ID, capture and judge in oneditequaltion, and perform logical operations.
Android: imeActionLabel: sets the IME action label. But it cannot be guaranteed to be used. I guess it should be useful when the input method is extended.
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 the complete package name must be fully qualified ). For example, com. google. android. inputmethod. pinyin, but the error cannot be found. For more information about custom input methods, see here.
Android: inputType sets the text type to help the input method display the appropriate keyboard type. The following settings are available: none, text, textCapCharacters Letter size, textCapWords first letter size, textCapSentences only the first letter size, textAutoCorrect, textAutoComplete Automatic completion, textMultiLine multi-line input, textImeMultiLine input multi-line if supported) textNoSuggestions does not prompt, The textEmailAddress email address, the textEmailSubject email subject, and the textmediamessage will receive an emoticons button, as shown in the following figure:
), TextLongMessage long message? TextPersonName, textPostalAddress, textPassword, textVisiblePassword, textWebEditText, textWebEditText, textFilte, textPhonetic Pinyin input, numberSigned signed numeric format, numberDecimal floating Point format, phone number, datetime time date, date, and time. For more information, see here.
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. See this attribute in TextView.
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 number of input characters. If it is set to 5, you can enter only five Chinese characters, numbers, and English letters.
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: linksClickable sets whether the link is connected even if autoLink is set.
Android: lineSpacingExtra.
Android: lineSpacingMultiplier. For example, "1.2"
Android: If numeric is set, the TextView has a digital input method. It has the following values: integer positive integer, signed integer, and decimal floating point number.
Android: the password is displayed as a small dot ".".
Android: Set phoneNumber to the phone number input method.
Android: privateImeOptions provides additional input methods (string format ). Determine whether to provide the service based on the input method, as shown in the following figure. The custom Input Method inherits InputMethodService. This article may be helpful.
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. See this attribute in TextView.
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: 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. The configurable values are as follows:
- textAppearanceButton
- textAppearanceInverse
- textAppearanceLarge
- textAppearanceLargeInverse
- textAppearanceMedium
- textAppearanceMediumInverse
- textAppearanceSmall
- textAppearanceSmallInverse
Android: textColor set text color
Android: the background color of the selected text in textColorHighlight. The default value is blue.
Android: textColorHint sets the text color of the prompt message. The default value is gray. Used with hint.
Android: The color of textColorLink text link.
Android: textScaleX sets the interval between texts. The default value is 1.0f. See TextView.
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: normal0, sans1, serif2, 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.
3. Android API example
- <! -- [Endif] --> android: imeOptions example
-
- <EditText android: id = "@ + id/txtTest" android: imeOptions = "actionGo"
- Android: layout_width = "100dp" android: layout_height = "wrap_content"> </EditText>
-
- (Edittext=findviewbyid(r.id.txt Test). setoneditexceptionlistener (new TextView. oneditexceptionlistener (){
- @ Override
- Public boolean oneditequaltion (TextView v, int actionId,
- KeyEvent event ){
- If (actionId = EditorInfo. IME_ACTION_GO ){
- Toast. makeText (TestActivity. this, "you clicked Go! ", Toast. LENGTH_SHORT). show ();
- }
- Return false;
- }
- });
Summary:Android APIThe content of the EditText in the Chinese document is complete.Android APIContent learning is helpful to you ~