android開發之EditText的屬性說明

來源:互聯網
上載者:User

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"

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.