Android,TextView的所有屬性和方法


XML 屬性

屬性名稱

相關方法

描述

android:autoLink

setAutoLinkMask(int)

設置是否當文本為URL鏈接/email/電話號碼/map時,文本顯示為可點擊的鏈接。可選值(none/web/email/phone/map/all)

android:autoText

setKeyListener(KeyListener)

如果設置,將自動執行輸入值的拼寫糾正。此處無效果,在顯示輸入法並輸入的時候起作用。

android:bufferType

setText(CharSequence,TextView.BufferType)

指定getText()方式取得的文本類別。

android:capitalize

setKeyListener(KeyListener)

設置英文字母大寫類型。

android:cursorVisible

setCursorVisible(boolean)

設定光標為顯示/隱藏,默認顯示。

android:digits

setKeyListener(KeyListener)

設置允許輸入哪些字符。如“1234567890.+-*/%\n()”

android:drawableBottom

setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)

在text的下方輸出一個drawable.

android:drawableLeft

setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)

在text的左邊輸出一個drawable,如圖片。

android:drawablePadding

setCompoundDrawablePadding(int)

設置text與drawable(圖片)的間隔,與drawableLeft、drawableRight、drawableTop、drawableBottom一起使用,可設置為負數,單獨使用沒有效果。

android:drawableRight

setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)

在text的右邊輸出一個drawable,如圖片。

android:drawableTop

setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)

在text的正上方輸出一個drawable,如圖片。

android:editable

設置是否可編輯。這里無效果,參見EditView。

android:editorExtras

setInputExtras(int)

設置文本的額外的輸入數據。

android:ellipsize

setEllipsize(TextUtils.TruncateAt)

設置當文字過長時,該控件該如何顯示。有如下值設置:”start”—–省略號顯示在開頭;”end”——省略號顯示在結尾;”middle”—-省略號顯示在中間;”marquee” ——以跑馬燈的方式顯示(動畫橫向移動)

android:ems

setEms(int)

設置文本域的長度為 所定義的em

android:freezesText

setFreezesText(boolean)

設置保存文本的內容以及光標的位置。

android:gravity

setGravity(int)

設置文本位置,如設置成“center”,文本將居中顯示。

android:height

setHeight(int)

設置文本域的高度為所定義的值

android:hint

setHint(int)

Text為空時顯示的文字提示信息,可通過textColorHint設置提示信息的顏色。

android:imeActionId

setImeActionLabel(CharSequence,int)

設置右下角EditorInfo.actionId與編輯框相關的動作。

android:imeActionLabel

setImeActionLabel(CharSequence,int)

設置IME動作標簽 EditorInfo.actionLabel與編輯框相關的動作。

android:isScrollContainer

附加功能,設置右下角IME動作與編輯框相關的動作.

android:keepScreenOn

setKeepScreenOn(boolean)

設置文本是否包含頂部和底部額外空白,默認為true。

android:layerType

setLayerType(int,Paint)

為文本指定輸入法,需要完全限定名(完整的包名)。

android:longClickable

setLongClickable(boolean)

設置文本的類型,用於幫助輸入法顯示合適的鍵盤類型。

android:minHeight

設置行間距。

android:minWidth

設置行間距的倍數。如”1.2”

android:nextFocusDown

setNextFocusDownId(int)

Defines the next view to give focus to when the next focus is FOCUS_DOWN If the reference refers to a view that does not exist or is part of a hierarchy that is invisible, a RuntimeException will result when the reference is accessed. 

android:nextFocusForward

setNextFocusForwardId(int)

設置鏈接是否點擊連接,即使設置了autoLink。

android:nextFocusLeft

setNextFocusLeftId(int)

在ellipsize指定marquee的情況下,設置重復滾動的次數,當設置為marquee_forever時表示無限次。

android:nextFocusRight

setNextFocusRightId(int)

設置TextView的寬度為最長為N個字符的寬度。

android:nextFocusUp

setNextFocusUpId(int)

設置TextView的寬度為最短為N個字符的寬度。

android:onClick

設置文本區域的最大高度

android:padding

setPadding(int,int,int,int)

設置文本的最大顯示行數,與width或者layout_width結合使用,超出部分自動換行,超出行數將不顯示。

android:paddingBottom

setPadding(int,int,int,int)

設置文本區域的最大寬度

android:paddingLeft

setPadding(int,int,int,int)

Sets the padding, in pixels, of the left edge; seepadding. 

android:paddingRight

setPadding(int,int,int,int)

設置文本區域的最小高度

android:paddingTop

setPadding(int,int,int,int)

設置文本的最小行數.

android:rotation

setRotation(float)

設置文本區域的最小寬度

android:rotationX

setRotationX(float)

如果被設置,該TextView有一個數字輸入法。

android:rotationY

setRotationY(float)

以小點”.”顯示文本

android:saveEnabled

setSaveEnabled(boolean)

設置為電話號碼的輸入方式。

android:scaleX

setScaleX(float)

設置輸入法選項

android:scaleY

setScaleY(float)

設置文本超出TextView的寬度的情況下,是否出現橫拉條。

android:scrollX

如果文本是可選擇的,讓他獲取焦點而不是將光標移動為文本的開始位置或者末尾位置。EditText中設置后無效果。

android:scrollY

指定文本陰影的顏色,需要與shadowRadius一起使用。

android:scrollbarAlwaysDrawHorizontalTrack

設置陰影橫向坐標開始位置。

android:scrollbarAlwaysDrawVerticalTrack

設置陰影縱向坐標開始位置。

android:scrollbarDefaultDelayBeforeFade

設置陰影的半徑。設置為0.1就變成字體的顏色了,一般設置為3.0的效果比較好。

android:scrollbarFadeDuration

設置單行顯示。如果和layout_width一起使用,當文本不能全部顯示時,后面用“…”來表示。

android:scrollbarSize

設置顯示文本.

android:scrollbarStyle

設置文字外觀。如顏色,字體等

android:scrollbarThumbHorizontal

設置文本顏色

android:scrollbarThumbVertical

被選中文字的底色,默認為藍色

android:scrollbarTrackHorizontal

設置提示信息文字的顏色,默認為灰色。與hint一起使用

android:scrollbarTrackVertical

文字鏈接的顏色.

android:scrollbars

Defines which scrollbars should be displayed on scrolling or not. 

android:soundEffectsEnabled

setSoundEffectsEnabled(boolean)

設置文字之間間隔,默認為1.0f。

android:tag

設置文字大小.

android:transformPivotX

setPivotX(float)

設置字形[bold(粗體) 0, italic(斜體) 1, bolditalic(又粗又斜) 2] 可以設置一個或多個,用“|”隔開

android:transformPivotY

setPivotY(float)

設置文本字體,必須是以下常量值之一:normal 0, sans 1, serif 2, monospace(等寬字體) 3]

android:translationX

setTranslationX(float)

translation in x of the view. 

android:translationY

setTranslationY(float)

translation in y of the view. 

android:visibility

setVisibility(int)

Controls the initial visibility of the view. 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM