EditText的屬性


EditText的屬性
本文主要研究一下EditText的屬性(還沒研究完,邊研究邊寫)

android:layout_gravity="center_vertical"//
設置控件顯示的位置:默認top,這裏居中顯示,還有bottom

android:hint="
請輸入數字!"//設置顯示在空間上的提示信息

android:numeric="integer"//
設置只能輸入整數,如果是小數則是:decimal

android:singleLine="true"//
設置單行輸入,一旦設置爲true,則文字不會自動換行。

<!--


android:gray="top" //
多行中指針在第一行第一位置

et.setSelection(et.length());//
調整光標到最後一行

Android:autoText//
自動拼寫幫助

Android:capitalize//
首字母大寫

Android:digits//
設置只接受某些數字

Android
:singleLine //是否單行或者多行,回車是離開文本框還是文本框增加新行

Android
:numeric //只接受數字

Android
:password //密碼

Android
:phoneNumber // 輸入電話號碼

Android
:editable //是否可編輯

Android:autoLink=
”all” //設置文本超鏈接樣式當點擊網址時,跳向該網址

android:password="true"//
設置只能輸入密碼

android:textColor= "#ff8c00"//
字體顏色

android:textStyle="bold"//
字體,bold, italic,bolditalic

android:textSize="20dip"//
大小

android:capitalize= "characters"//
以大寫字母寫

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"//
文字外觀,這裏引用的是系統自帶的一個外觀,?表示系統是否有這種外觀,否則使用默認的外觀。不知道這樣理解對不對?

 屬性名稱描述
  android:autoLink設置是否當文本爲URL鏈接/email/電話號碼/map時,文本顯示爲可點擊的鏈接。可選值(none/web/email/phone/map/all)
  android:autoText如果設置,將自動執行輸入值的拼寫糾正。此處無效果,在顯示輸入法並輸入的時候起作用。
  android:bufferType指定getText()方式取得的文本類別。選項editable 類似於StringBuilder可追加字符,
  也就是說getText後可調用append方法設置文本內容。spannable 則可在給定的字符區域使用樣式,參見這裏1、這裏2。
  android:capitalize設置英文字母大寫類型。此處無效果,需要彈出輸入法才能看得到,參見EditView此屬性說明。
  android:cursorVisible設定光標爲顯示/隱藏,默認顯示。
  android:digits設置允許輸入哪些字符。如“1234567890.+-*/%()”
  android:drawableBottom在text的下方輸出一個drawable,如圖片。如果指定一個顏色的話會把text的背景設爲該顏色,並且同時和background使用時覆蓋後者。
  android:drawableLeft在text的左邊輸出一個drawable,如圖片。
  android:drawablePadding設置text與drawable(圖片)的間隔,與drawableLeft、drawableRight、drawableTop、drawableBottom一起使用,可設置爲負數,單獨使用沒有效果。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章