Set the indent of the first line of TextView in Android

Source: Internet
Author: User
Tags gettext numeric


In the text typesetting often want to set the first line indent, use Word will know, then in Android when you need to set the first line indent when the swollen do it, I summed up two ways:



The first kind: The Fool type, the space acts as (8 space occupies two Chinese characters size).




Textview.settext (" Set first-line indent setting first-line indent setting first-line indent setting first-line indentation setting first-line indent set top indent setting first line indent setting first indent line indent setting first line indent setting first line indent setting first line indent setting first indent setting first line indent setting the first indentation "");
Second: escape characters.



Textview.settext ("\u3000\u3000" + " Set first-line indent setting first-line indent setting first-line indent setting first-line indentation setting first-line indent set top indent setting first line indent setting first indent line indent setting first line indent setting first line indent setting first line indent setting first indent setting first line indent setting the first indentation "");

TextView Property

Attribute Name Description
Android:autolink whether the text is displayed as a clickable link when the text is a URL link/email/phone number/map. Optional value (None/web/email/phone/map/all)
Android:autotext if set, the spelling correction for the input value is automatically performed. No effect here, it works when the input input is displayed.
ANDROID:BUFFERTYPE Specifies the type of text that the GetText () method obtains. The option editable is similar to StringBuilder can append characters,
That is, GetText can call the Append method to set the text content. Spannable can use styles in a given character area, see here 1, here 2.



Android:capitalize sets the English letter capitalization type. No effect here, you need to eject the input method to see it, see editview this property description.
Android:cursorvisible set cursor for show/hide, default display.
The Android:digits setting allows you to enter which characters. such as "1234567890.+-*/%\n ()"
Android:drawablebottom prints a drawable below the text, such as a picture. If you specify a color, the text background is set to the color, and the latter is overwritten with background.
Android:drawableleft prints a drawable on the left side of the text, such as a picture.
Android:drawablepadding sets the spacing between text and drawable (picture), and is used in conjunction with Drawableleft, Drawableright, Drawabletop, Drawablebottom, Can be set to a negative number, with no effect alone.
Android:drawableright prints a drawable on the right side of the text, such as a picture.
Android:drawabletop outputs a drawable, such as a picture, above the text.
Whether the android:editable setting is editable. There is no effect here, see EditView.
Android:editorextras sets the additional input data for the text. Discuss it again in EditView.
Android:ellipsize sets how the control should appear when the text is too long. The following values are set: the "Start"-– ellipses are displayed at the beginning; "End"--ellipses are displayed at the ends; "Middle"--ellipses are displayed in the middle; "Marquee"--Display as a marquee (animation moves horizontally)



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



Android:gravity sets the text position, as set to "center," and the text is centered.
Android:hint text message displayed when the text is empty, you can set the color of the hint message by Textcolorhint. This property is used in EditView, but can also be used here.
Android:imeoptions additional function, set the lower right corner IME action related to the edit box action, such as Actiondone in the lower right corner will display a "finish" instead of setting the default is a carriage return symbol. This is explained in detail in the EditView, which is useless here.
Android:imeactionid Sets the IME action ID. In EditView again to do the explanation, you can read this post: here.


Android:imeactionlabel Sets the IME action label. Make a note in EditView.
Android:includefontpadding sets whether the text contains extra white space at the top and bottom, and defaults to true.
ANDROID:INPUTMETHOD specifies the input method for text, requiring a fully qualified name (the full package name). For example: Com.google.android.inputmethod.pinyin, but here the error is not found.
Android:inputtype sets the type of text to help the input method display the appropriate keyboard type. In EditView, there is no effect.
Android:marqueerepeatlimit sets the number of repeat scrolling when ellipsize specifies marquee, which is infinite when set to Marquee_forever.
Android:ems sets the width of the TextView to n characters. This test is for a character width of Chinese characters, as shown in figure:
Android:maxems sets the width of the textview to a maximum of n characters. Override the EMS option when used in conjunction with EMS.
Android:minems sets the width of the textview to a minimum of n characters. Override the EMS option when used in conjunction with EMS.
Android:maxlength limits the length of text that is displayed and is not displayed beyond the section.
Android:lines sets the number of lines of text, setting two lines to display two lines, even if there is no data in the second row.
Android:maxlines sets the maximum number of lines of text to display, in conjunction with the width or layout_width, which exceeds the number of wrapping lines, and does not show up.
Android:minlines sets the minimum number of lines of text, similar to lines.
Android:linksclickable set the link to click on the connection, even if setting the Autolink.
Android:linespacingextra sets the line spacing.
Android:linespacingmultiplier sets the multiple of line spacing. such as "1.2"
Android:numeric if it is set, the TextView has a numeric input method. This is useless, the only effect after setting is TextView has a click Effect, this property will be detailed in Edtiview.
Android:password with a small dot "." Display text
Android:phonenumber is set to the way the phone number is entered.
Android:privateimeoptions setting Input method options, which are useless here, will be discussed further in EditText.
android:scrollhorizontally If the text is set to exceed the width of the TextView, the horizontal pull bar appears.
Android:selectallonfocus If the text is selectable, let him get 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, which needs to be used with Shadowradius. Effect:
ANDROID:SHADOWDX sets the position of the shadow's horizontal coordinates to begin.
Android:shadowdy sets the position of the shadow portrait coordinates to begin.
Android:shadowradius sets the radius of the shadow. Set to 0.1 to become the color of the font, the general set to 3.0 the effect is better.
Android:singleline set up a single-line display. If used with Layout_width, when the text cannot be all displayed, the following is indicated 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 false, the text wraps automatically.
Android:text sets the display text.
Android:textappearance sets the appearance of the text. such as "? Android:attr/textappearancelargeinverse
"Here is a reference to the system's own appearance,?" Indicates whether the system has this appearance, otherwise the default appearance is used. The values you can set are as follows: textappearancebutton/textappearanceinverse/textappearancelarge/textappearancelargeinverse/ Textappearancemedium/textappearancemediuminverse/textappearancesmall/textappearancesmallinverse
Android:textcolor Set Text color
Android:textcolorhighlight the background of the selected text, the default is blue
Android:textcolorhint sets the color of the hint message text, which defaults to Gray. Used in conjunction with hint.
Android:textcolorlink the color of the text link.
Android:textscalex sets the spacing between text, which defaults to 1.0f. The 0.5f/1.0f/1.5f/2.0f effects are set separately as follows:

Android:textsize set the text size, recommend the unit of measure "SP", such as "15SP"
Android:textstyle set glyph [Bold (bold) 0, Italic (italic) 1, bolditalic (Bold and oblique) 2] can be 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 set the height of the text area, support unit of measure: px (pixel)/dp/sp/in/mm (mm)
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, which supports the unit of measure: px (pixel)/dp/sp/in/mm (mm), and layout_width difference look here.


Android:maxwidth sets the maximum width of the text area
Android:minwidth sets the minimum width of the text area





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.