EditText繼承關係:View-->TextView-->EditText。
EditText的屬性很多,這裡介紹幾個:
android:layout_gravity="center_vertical"
設定控制項顯示的位置:預設top,這裡置中顯示,還有bottom
android:hint="請輸入數字!"
設定顯示在空間上的提示資訊
android:numeric="integer"
設定只能輸入整數,如果是小數則是:decimal
android:singleLine="true"
設定單行輸入,一旦設定為true,則文字不會自動換行。
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"