Android筆記-3-EditText的屬性介紹

OuZeBo發表於2015-07-27

【Android 基礎】EditText的屬性介紹

EditText繼承TextView,所以EditText具有TextView的屬性特點,下面主要介紹一些EditText的特有的輸入法的屬性特點

android:layout_gravity="center_vertical":設定控制元件顯示的位置:預設top,這裡居中顯示,還有bottom

android:hin:Text為空時顯示的文字提示資訊,可通過textColorHint設定提示資訊的顏色。
 
android:singleLine:設定單行輸入,一旦設定為true,則文字不會自動換行。
 
android:gray="top" :多行中指標在第一行第一位置et.setSelection(et.length());:調整游標到最後一行
 
android:autoText :自動拼寫幫助。這裡單獨設定是沒有效果的,可能需要其他輸入法輔助才行
 
android:capitalize :設定英文字母大寫型別。設定如下值:sentences僅第一個字母大寫;words每一個單詞首字母大小,用空格區分單詞;characters每一個英文字母都大寫。
 
android:digits :設定允許輸入哪些字元。如“1234567890.+-*/%\n()”
 
android:singleLine :是否單行或者多行,回車是離開文字框還是文字框增加新行android:numeric :如果被設定,該TextView接收數字輸入。有如下值設定:integer正整數、
signed帶符號整數、decimal帶小數點浮點數。
 
android:inputType:設定文字的型別
 
android:password :密碼,以小點”.”顯示文字
 
android:phoneNumber :設定為電話號碼的輸入方式。
 
android:editable :設定是否可編輯。仍然可以獲取游標,但是無法輸入。
 
android:autoLink=”all” :設定文字超連結樣式當點選網址時,跳向該網址
 
android:textColor = "#ff8c00":字型顏色
 
android:textStyle="bold":字型,bold, italic, bolditalic
 
android:textAlign="center":EditText沒有這個屬性,但TextView有
 
android:textColorHighlight="#cccccc":被選中文字的底色,預設為藍色
 
android:textColorHint="#ffff00":設定提示資訊文字的顏色,預設為灰色
 
android:textScaleX="1.5":控制字與字之間的間距
 
android:typeface="monospace":字型,normal, sans, serif, monospace
 
android:background="@null":空間背景,這裡沒有,指透明
 
android:layout_weight="1":權重在控制控制元件顯示的大小時蠻有用的。
 
android:textAppearance="?android:attr/textAppearanceLargeInverse":文字外觀,這裡引用的是系統自帶的一個外觀,?表示系統是否有這種外觀,否則使用預設的外
觀。
 
 
來源:http://liangruijun.blog.51cto.com/3061169/627350

相關文章