Android edit box (EditText) attribute learning

Source: Internet
Author: User
Tags gettext

EditText Inheritance Relationship: View-->textview-->edittext

  EditText has a lot of properties, here are a few:
Android:hint= "Please enter a number!" "//Set the information displayed on the space
Android:numeric= "integer"//set to enter only integers, if decimal: decimal
Android:singleline= "true"//sets single-line input, and once set to true, the text will not wrap automatically.
Android:password= "true"//setting can only enter password
Android:textcolor= "#ff8c00"//Font Color
Android:textstyle= "bold"//font, bold, italic, Bolditalic
android:textsize= "20dip"//Size
android:capitalize= "Characters"//write in uppercase letters
android:textalign= "Center"//edittext does not have this attribute, but TextView has, center
Android:textcolorhighlight= "#cccccc"//Background of selected text, blue by default
Android:textcolorhint= "#ffff00"//Set the color of the message text, default is gray android:textscalex= "1.5"//control the spacing between word and word
Android:typeface= "monospace"//font, normal, sans, serif, monospace (standard, sans serif font, serif font, equal width font)
Android:background= "@null"//background, not here, refers to transparent
Android:layout_weight= "1"//weight, controls the position between controls, which is useful when controlling the size of the control display.
android:textappearance= "? android:attr/textappearancelargeinverSe "//Text appearance
android:layout_gravity= "Center_vertical"//Set control display location: Default top, centered here, and bottom

android:gray= "Top"//multi-line pointer on first row first position

et.setselection (Et.length ());//Adjust the cursor to the last line

Android:autotextAutomatic spelling Help

android:capitalizeCapitalize first letter

android:digitsSet to accept only certain numbers

Android:singlelineWhether a single line or multiple rows, enter is to leave the text box or text box to add a new line

Android:numericAccept numbers only

Android:phonenumberEnter phone number

android:editableWhether it can be edited

Android:autolink= "All"//Set text hyperlink style when you click the URL, skip to the URL

android:textappearance= "? android:attr/textappearancelargeinverSe "//text appearance, which refers to the system comes with an appearance,? Indicates whether the system has this appearance, otherwise the default appearance is used. I don't know if I understand that, right?


  Property Name Description

   Android:autolinkSets whether text is displayed as a clickable link when the text is a URL link/email/phone number/map. Selectable VALUES (None/web/email/phone/map/all)

   Android:autotextIf set, the spelling correction of the input values will be performed automatically. There is no effect here, it works when the input method is displayed and entered.

   Android:buffertypeSpecifies the text category that is obtained by the GetText () method. The option editable is similar to the StringBuilder append character,

That is, you can call the Append method to set the text content after gettext. Spannable can use the style in a given character area, see here 1, here 2.

   android:capitalizeSets the English letter capitalization type. There is no effect here, you need to pop up the input method to see, see EditView this property description.

   android:cursorvisibleSet the cursor to show/hide and display by default.

   android:digitsSets which characters are allowed to be entered. such as "1234567890.+-*/% ()"

   Android:drawablebottomOutput a drawable, slice, below the text. If you specify a color, the background of text is set to that color, and the latter is overridden when used with background.

   Android:drawableleftOutput a drawable on the left side of text, slice.

   android:drawablepaddingSets the interval between text and drawable (picture), used with Drawableleft, Drawableright, Drawabletop, Drawablebottom, and can be set to negative numbers, with no effect on its own.

Android:drawablerightOn the right side of text, output a drawable, slice.

Android:drawabletopOutput a drawable, a slice, directly above the text.

android:editableSets whether it can be edited. There is no effect here, see EditView.

Android:editorextrasSets the additional input data for the text. discussed again in EditView.

android:ellipsizeSets how the control is displayed when the text is too long. The following values are set: "Start"-the ellipsis is displayed at the beginning; End "--the ellipsis appears at the end; Middle "--the ellipsis appears in the middle; Marquee "--display in the form of a marquee (animated lateral movement)

Android:freezestextSets the contents of the saved text and the position of the cursor. See also: here.

android:gravitySets the text position, as set to center, and the text is centered.

Android:hinttextThe text message that is displayed when empty, you can set the color of the hint information by Textcolorhint. This property is used in EditView, but can also be used here.

android:imeoptionsAdditional functions, set the action associated with the edit box in the lower right corner of the IME action, such as the lower right corner of the Actiondone will display a "done", without setting the default is a carriage return symbol. This is explained in detail in EditView, which is useless here.

Android:imeactionidSets the IME action ID. In EditView again to do the instructions, you can read this post: here.

Android:imeactionlabelSets the IME action label. Explain it again in EditView.
android:includefontpaddingSets whether the text contains extra white space at the top and bottom, which defaults to true.
Android:inputmethodSpecifying an input method for text requires a fully qualified name (the full package name). For example: Com.google.android.inputmethod.pinyin, but the error is not found here.
Android:inputtypeSets the type of text that is used to help the input method display the appropriate keyboard type. Detailed in the EditView, there is no effect here.
android:linksclickableSets whether the link clicks the connection, even if the Autolink is set.
Android:marqueerepeatlimitSets the number of times to repeat scrolling when ellipsize specifies marquee, which is expressed indefinitely when set to Marquee_forever.
Android:emsSets the width of the TextView to n characters. Here the test is a Chinese character width,
Android:maxemsSets the width of the textview to a maximum of n characters. Overwrite EMS option when used with EMS.
Android:minemsSets the width of the textview to a minimum of n characters. Overwrite EMS option when used with EMS.
Android:maxlengthLimits the length of text that is displayed, which is not displayed.
Android:linesSets the number of lines of text, two lines are displayed, even if the second row has no data.
Android:maxlinesSets the maximum number of lines of text to display, in combination with width or layout_width, beyond the partial wrap, beyond the number of lines that are not displayed.
Android:minlinesSets the minimum number of lines of text, similar to lines.
Android:linespacingextraSets the line spacing.
Android:linespacingmultiplierSets the multiple of line spacing. such as "1.2"
Android:numericIf set, the TextView has a numeric input method. It is useless here, the only effect after setting is TextView has the click Effect, this property will be explained in detail in Edtiview.
Android:passwordWith a small dot "." Display text
Android:phonenumberSet the input method for the phone number.
android:privateimeoptionsSetting IME options is useless here, and will be discussed further in EditText.
android:scrollhorizontallyIf you set the text to exceed the width of the TextView, the horizontal pull bar appears.
Android:selectallonfocusIf the text is selectable, let him get the focus instead of moving the cursor to the beginning or end of the text. No effect after setting in TextView.
Android:shadowcolorSpecifies the color of the text shadow, which needs to be used with Shadowradius. Effect:

ANDROID:SHADOWDXSets the start position of the shadow's horizontal coordinates.

Android:shadowdySets the start position of the shadow vertical coordinates.

Android:shadowradiusSets the radius of the shadow. Set to 0.1 to become the color of the font, generally set to 3.0 effect is better.

Android:singlelineSets the single-line display. If used with Layout_width, when the text cannot be displayed in its entirety, it is followed by "...". such as android:text= "Test_ singleline" android:singleline= "true" android:layout_width= "20DP" will show only "t ...". If you do not set Singleline or set to False, the text wraps automatically

ANDROID:SHADOWDX sets the start position of the shadow horizontal coordinates.

Android:shadowdy sets the start position of the shadow vertical coordinates.

Android:shadowradius sets the radius of the shadow. Set to 0.1 to become the color of the font, generally set to 3.0 effect is better.

Android:singleline sets the single-line display. If used with Layout_width, when the text cannot be displayed in its entirety, it is followed by "...". such as android:text= "Test_ singleline" android:singleline= "true" android:layout_width= "20DP" will show only "t ...". If you do not set Singleline or set to False, the text wraps automatically

Android:text sets the display text.

Android:textsize set text size, recommended unit of measure "SP", such as "15SP"

Android:textstyle set glyph [Bold (bold) 0, Italic (italic) 1, bolditalic (coarse and oblique) 2] You can set one or more, with "|" Separated

Android:typeface Set the text font, must be one of the following constant values: normal 0, sans 1, serif 2, monospace (equal width font) 3]

Android:height Setting the height of the text area, support measurement: px (pixels)/dp/sp/in/mm (mm)

Android:maxheight Setting the maximum height of the text area

Android:minheight Setting the minimum height of the text area

Android:width sets the width of the text area, supported by the measurement: px (pixels)/dp/sp/in/mm (mm), and the difference between layout_width look here.

Android:maxwidth Setting the maximum width of the text area

Android:minwidth Setting the minimum width of the text area

Android:textappearance to set the appearance of text. such as "? Android:attr/textappearancelargeinverSe "refers to the system comes with a look,?" Indicates whether the system has this appearance, otherwise use the default appearance. The values you can set are as follows: Textappearancebutton/textappearanceinverse/textappearancelarge/textappearancelargeinverSe/textappearancemedium/textappearancemediuminveRse/textappearancesmall/textappearancesmallinverSe

Android:textappearance to set the appearance of text. such as "? Android:attr/textappearancelargeinverSe

"This refers to the appearance of the system comes with," said the system has this appearance, otherwise use the default appearance. The values you can set are as follows:

Textappearancebutton/textappearanceinverse/textappearancelarge/textappearancelargeinverSE

Android edit box (EditText) attribute learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.