基于Android 2.3 的EditText各種屬性

在android2.3版本,許多edittext屬性不建議使用了,那么這些不建議使用的屬性都去哪了?官方也不可能將這些屬性全部移除拉!看下面屬性詳解吧

各種方便拖動(dòng)的EditText

看上面id的意思,我想也特別的明白了,ok!下面就介紹EditText各種屬性。

android:layout_gravity="center_vertical"http://設(shè)置控件顯示的位置:默認(rèn)top,這里居中顯示,還有bottom

android:hint="請(qǐng)輸入數(shù)字!"http://設(shè)置顯示在ui上的提示信息

Android:digits //設(shè)置只接受某些數(shù)字

Android:lines //代替singleLine

Android:ellipsize = "end"  ? 省略號(hào)在結(jié)尾

Android:ellipsize = "start"?  省略號(hào)在開頭

Android:ellipsize = "middle" ? ??省略號(hào)在中間

Android:ellipsize = "marquee" ?跑馬燈

Android:singleline = "true"

Android:ems = "10" 設(shè)置TextView或者Edittext的寬度為10個(gè)字符的寬度。當(dāng)設(shè)置該屬性后,控件顯示的長(zhǎng)度就為10個(gè)字符的長(zhǎng)度,超出的部分將不顯示。Android:numeric //只接受數(shù)字

Android:autoLink=”all” //設(shè)置文本超鏈接樣式當(dāng)點(diǎn)擊網(wǎng)址時(shí),跳向該網(wǎng)址

android:password="true"http://設(shè)置只能輸入密碼

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

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

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

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

android:textAlign="center"http://EditText沒有這個(gè)屬性,但TextView有

android:textColorHighlight="#cccccc"http://被選中文字的底色,默認(rèn)為藍(lán)色

android:textColorHint="#ffff00"http://設(shè)置提示信息文字的顏色,默認(rèn)為灰色

android:textScaleX="1.5"http://控制字與字之間的間距

android:typeface="monospace"http://字型,normal, sans, serif, monospace

android:background="@null"http://空間背景,這里沒有,指透明

android:layout_weight="1"http://權(quán)重 在控制控 ? 件顯示的大小時(shí)蠻有用的。

android:textAppearance="?android:attr/textAppearanceLargeInverse"http://文字外觀,這里引用的是系統(tǒng)自帶的一個(gè)外觀,?表示系統(tǒng)是否有這種外觀,否則使用默認(rèn)的外觀。不知道這樣理解對(duì)不對(duì)?

我就在想,那么許多屬性不建議使用?原來全部都塞到了inputType里面了。當(dāng)然,Android中inputType屬性在EditText輸入值時(shí)啟動(dòng)的虛擬鍵盤的風(fēng)格有著重要的作用。這也大大的方便的操作。有時(shí)需要虛擬鍵盤只為字符或只為數(shù)字。

android:inputType="none"

android:inputType="text"http://配合lines使用

android:inputType="textCapCharacters" 字母大寫

android:inputType="textCapWords" 首字母大寫

android:inputType="textCapSentences" 僅第一個(gè)字母大寫

android:inputType="textAutoCorrect" 自動(dòng)完成

android:inputType="textAutoComplete" 自動(dòng)完成

android:inputType="textMultiLine" 多行輸入

android:inputType="textImeMultiLine" 輸入法多行(如果支持)

android:inputType="textNoSuggestions" 不提示

android:inputType="textUri" 網(wǎng)址

android:inputType="textEmailAddress" 電子郵件地址

android:inputType="textEmailSubject" 郵件主題

android:inputType="textShortMessage" 短訊

android:inputType="textLongMessage" 長(zhǎng)信息

android:inputType="textPersonName" 人名

android:inputType="textPostalAddress" 地址

android:inputType="textPassword" 密碼

android:inputType="textVisiblePassword" 可見密碼

android:inputType="textWebEditText" 作為網(wǎng)頁表單的文本

android:inputType="textFilter" 文本篩選過濾

android:inputType="textPhonetic" 拼音輸入 //數(shù)值類型

android:inputType="number" 數(shù)字

android:inputType="numberSigned" 帶符號(hào)數(shù)字格式

android:inputType="numberDecimal" 帶小數(shù)點(diǎn)的浮點(diǎn)格式

android:inputType="phone" 撥號(hào)鍵盤

android:inputType="datetime" 時(shí)間日期

android:inputType="date" 日期鍵盤

android:inputType="time" 時(shí)間鍵盤

這些都是最常用的各種EditText的屬性了。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 172,841評(píng)論 25 708
  • RelativeLayout 第一類:屬性值為true可false android:layout_centerHr...
    兀兀沙彌閱讀 3,023評(píng)論 0 15
  • 歡迎Follow我的GitHub, 關(guān)注我的CSDN. 其余參考Android目錄. 轉(zhuǎn)載請(qǐng)注明出處:http:/...
    passiontim閱讀 4,797評(píng)論 0 31
  • Its the first day that i come back to china. 每次回來國(guó)內(nèi),總是會(huì)有與...
    英日粵語口譯Jack閱讀 109評(píng)論 0 0
  • 記得我小學(xué)的時(shí)候迷上了游戲,在畢業(yè)考的時(shí)候就輸了,我去了一個(gè)垃圾初中哪里,可以說差得,無法想象,到了初中因?yàn)閯e人的...
    我是豬豬喔閱讀 343評(píng)論 6 5