標籤:android style color 使用 os 檔案 io 資料
找了很多地方都沒看到,經過嘗試,發現這麼一種方法可以達到限定edittext中的字元。
android:digits="1234567890qwertyuiopasdfghjklzxcvbnm`-=[]\;,./[email protected]#$%^*()_+}{:?&<>"'"
裡面是可以輸入的字元,大家根據自己的需求添加。
再摘抄一部分其他前輩的博文,留做備份
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"
文字外觀,這裡引用的是系統內建的一個外觀,?表示系統是否有這種外觀,否則使用預設的外觀。不知道這樣理解對不對?
通過EditText的layout xml檔案中的相關屬性來實現:
1. 密碼框屬性 android:password="true" 這條可以讓EditText顯示的內容自動為星號,輸入時內容會在1秒內變成*字樣。
2. 純數字 android:numeric="true" 這條可以讓IME自動變為數字輸入鍵盤,同時僅允許0-9的數字輸入
3. 僅允許 android:capitalize="cwj1987" 這樣僅允許接受輸入cwj1987,一般用於密碼驗證//這一條是錯誤的,用我開頭的代替
下面是一些擴充的風格屬性
android:editable="false" 設定EditText不可編輯
android:singleLine="true" 強制輸入的內容在單行
android:ellipsize="end" 自動隱藏尾部溢出資料,一般用於文字內容過長一行無法全部顯示時
大家有什麼好玩的,好用的,歡迎告知我