Android components: TextView's properties

Source: Internet
Author: User

Android:autolink: Sets 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:autotext: If 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:buffertype: Specifies the text category that is obtained by the GetText () method. The option editable is similar to StringBuilder: an append character, which means that the Append method can be called to set the text content after gettext. Spannable: You can use the style in a given character area, see here 1, here 2.
Android:capitalize: Sets 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:cursorvisible: Set cursor to show/hide, default display.
Android:digits: Sets which characters are allowed to be entered. such as "1234567890.+-*/% ()"
Android:drawablebottom: Output 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:drawableleft: Output A drawable, slice on the left side of text.
Android:drawablepadding: Sets the interval between text and drawable (picture), used with Drawableleft, Drawableright, Drawabletop, Drawablebottom, Can be set to negative, no effect is used alone.
Android:drawableright: Outputs a drawable to the right of text.
Android:drawabletop: Outputs a drawable directly above the text.
Android:editable: Sets whether it can be edited.
Android:editorextras: Sets additional input data for the text.
Android:ellipsize: Sets 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:freezestext: Sets the contents of the saved text and the position of the cursor.
Android:gravity: Sets the text position, as set to "center", and the text is centered.
Android:hinttext: The text message displayed when empty, the color of the message can be set by Textcolorhint. This property is used in EditView, but can also be used here.
Android:imeoptions: Additional functions, set the lower right corner of the IME action related to the edit box action, such as the lower right corner of the Actiondone will display a "done", and not set the default is a carriage return symbol. This is explained in detail in EditView, which is useless here.
Android:imeactionid: Sets the IME action ID.
Android:imeactionlabel: Sets the IME action label.
Android:includefontpadding: Sets whether the text contains extra white space at the top and bottom, which defaults to true.
Android:inputmethod: Specifies the input method for text and requires a fully qualified name (full package name). For example: Com.google.android.inputmethod.pinyin, but the error is not found here.
Android:inputtype: Sets the type of text used to help the input method display the appropriate keyboard type. Detailed in the EditView, there is no effect here.
Android:linksclickable: Sets whether the link clicks the connection, even if Autolink is set.
Android:marqueerepeatlimit: Sets the number of times to repeat scrolling when ellipsize specifies marquee, which is expressed indefinitely when set to Marquee_forever.
Android:ems: Sets the width of the textview width to n characters. Test here for a Chinese character width
Android:maxems: Sets the width of the textview to a maximum of n characters. Overwrite EMS option when used with EMS.
Android:minems: Sets the width of the textview to a minimum of n characters. Overwrite EMS option when used with EMS.
Android:maxlength: Limit the length of text that is displayed, and the excess part is not displayed.
Android:lines: Sets the number of lines of text, two lines are displayed, even if the second row has no data.
Android:maxlines: Sets 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 to be displayed.
Android:minlines: Sets the minimum number of lines of text, similar to lines.
Android:linespacingextra: Sets the line spacing.
Android:linespacingmultiplier: Sets a multiple of the line spacing. such as "1.2"
Android:numeric: If 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:password: With a small dot "." Display text
Android:phonenumber: Sets the input method for the phone number.
Android:privateimeoptions: Setting IME options is useless here, and will be discussed further in EditText.
Android:scrollhorizontally: If the text exceeds the width of the TextView, the horizontal pull bar appears.
Android:selectallonfocus: If 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:shadowcolor: Specifies the color of the text shadow that needs to be used with Shadowradius.
ANDROID:SHADOWDX: Sets the start position of the shadow's 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 only show "t ...". If you do not set Singleline or set to False, the text wraps automatically
Android:text: Sets the display text.
Android:textappearance: Sets the appearance of text. As "? Android:attr/textappearancelargeinverse" here 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:textcolor: Setting text color
Android:textcolorhighlight: The background of the selected text, the default is blue
Android:textcolorhint: Sets the color of the message text, which is grayed out by default. Used in conjunction with hint.
Android:textcolorlink: The color of the text link.
Android:textscalex: Sets the spacing between text and defaults to 1.0f.
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: Sets the text font, which must be one of the following constant values: normal 0, sans 1, serif 2, monospace (equal width font) 3]
Android:height: Sets the height of the text area, supports the unit of measure: 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, supports the unit of measure: px (pixels)/dp/sp/in/mm (mm), and the difference between layout_width see here.
Android:maxwidth: Sets the maximum width of the text area
Android:minwidth: Sets the minimum width of the text area

Attachment: Length unit in Android

Length units in Android (DP, SP, PX, in, PT, mm) There are a lot of people who don't understand the difference between DP, SP, and PX: Now let's introduce the DP and SP. DP is also dip. This is basically similar to SP. You can use a DP or SP if you set properties that represent length, height, and so on. However, if you set the font, you need to use the SP. The DP is not density-independent, and the SP is not related to scale, except for density. If the screen density is 160, then the DP and SP and PX are the same. 1DP=1SP=1PX, but if you use PX as the unit, if the screen size is constant (assuming 3.2 inches), the screen density becomes 320. So the original width of the TextView is set to 160px, in the density of 320 of the 3.2-inch screen is more than the density of 160 of the 3.2-inch screen to see the half-short. But if it is set to 160DP or 160SP. The Width property value is automatically set to 320px. That means 160 * 320/160. 320/160 of these are called density scale factors. That is, if you use the DP and SP, the system will automatically convert based on the change in screen density.

Meaning of other units
PX: Indicates the actual pixel of the screen. For example, the 320*480 screen has 320 pixels in the landscape and 480 pixels in the portrait.
In: represents inches, which is the physical size of the screen. Equal to 2.54 centimeters per inch. For example, describe the size of a mobile phone screen, often said, 3.2 (English), 3.5 (English), 4 (English) inch refers to this unit. These dimensions are the diagonal length of the screen. If the phone's screen is 3.2 inches, the diagonal length of the phone's screen (viewable area) is 3.2*2.54 = 8.128 centimeters. Readers can measure their own phone screen to see if the actual size is the same.
MM: Represents the millimeter, which is the physical size of the screen.
PT: Represents a point, which is the physical size of the screen. Size is 1 inches of 1/72.

Android components: TextView's properties

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.