當前位置:首頁 » 安卓系統 » android文本輸入

android文本輸入

發布時間: 2025-02-26 19:20:13

① android 如何用代碼實現EditText控制項中只能輸入數字

數字<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
帶小數的數字 <EditText
android:id="@+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal" />
電話號碼的 <EditText
android:id="@+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone" />

② Android-EditView文本編輯控制項詳解

EditView 是Android開發當中運用到最多的控制項之一,主要用戶界面上的輸入框。

View --> TextView --> EditView 。

1.設置提示文本:

2.設置hint提示文字顏色:

3.設置輸入文本後的文字顏色:

4.設置輸入文本後的字體大小:

5.設置輸入文本後的字體樣式,bold(加粗),italic(傾斜),normal(默認是正常字體)。

6.設置被選中字體的顏色.默認為 Theme 主題中的 「colorAccent」的顏色。

7.設置被游標的顏色.默認為 Theme 主題中的 「colorAccent」的顏色。

8.設置文本的水平縮放系數。

9.設置hint提示文本的字體.normal(默認)\monospace\sans\serif。

10.設置EditText背景."@null"設置背景為透明.當我們設置背景後,EditText的下劃線就會消失。

11.設置文本的顏色,字體,大小和樣式。

12.設置只接收指定的文本內容,適合只能輸出特定內容的需求。

13.設置文本的類型,用於幫助輸入法顯示合適的鍵盤類型。

14.設置EditText最多接受的文本的個數:

15.設置EditText顯示的行數,設置兩行就顯示兩行,即使第二行沒有數據。

16.設置行間距的倍數. 如設置成1.5倍。

17.設置右下角IME動作與編輯框相關的動作,如actionDone右下角將顯示一個「完成」,而不設置默認是一個回車符號.

③ 屬性android:inputType用於設置文本輸入類型,其屬性值可以設置為以下哪些值

android:inputType="none"//輸入普通字元
android:inputType="text"//輸入普通字元
android:inputType="textCapCharacters"//輸入普通字元
android:inputType="textCapWords"//單詞首字母大小
android:inputType="textCapSentences"//僅第一個字母大小
android:inputType="textAutoCorrect"//前兩個自動完成
android:inputType="textAutoComplete"//前兩個自動完成
android:inputType="textMultiLine"//多行輸入
android:inputType="textImeMultiLine"//輸入法多行(不一定支持)
android:inputType="textNoSuggestions"//不提示
android:inputType="textUri"//URI格式
android:inputType="textEmailAddress"//電子郵件地址格式
android:inputType="textEmailSubject"//郵件主題格式
android:inputType="textShortMessage"//短消息格式
android:inputType="textLongMessage"//長消息格式
android:inputType="textPersonName"//人名格式
android:inputType="textPostalAddress"//郵政格式
android:inputType="textPassword"//密碼格式
android:inputType="textVisiblePassword"//密碼可見格式
android:inputType="textWebEditText"//作為網頁表單的文本格式
android:inputType="textFilter"//文本篩選格式
android:inputType="textPhonetic"//拼音輸入格式
//數值類型
android:inputType="number"//數字格式
android:inputType="numberSigned"//有符號數字格式
android:inputType="numberDecimal"//可以帶小數點的浮點格式
android:inputType="phone"//撥號鍵盤
android:inputType="datetime"//日期+時間格式
android:inputType="date"//日期鍵盤
android:inputType="time"//時間鍵盤

熱點內容
佳能c2220掃描後存儲 發布:2025-02-26 22:52:47 瀏覽:799
電腦我的世界怎麼玩手游的伺服器 發布:2025-02-26 22:52:36 瀏覽:149
壓縮天賦加點圖 發布:2025-02-26 22:51:05 瀏覽:395
編程找蘋果 發布:2025-02-26 22:38:49 瀏覽:341
河南助學貸款的登錄密碼是多少 發布:2025-02-26 22:37:33 瀏覽:47
oracle資料庫培訓班 發布:2025-02-26 22:35:56 瀏覽:897
如何假設傳奇伺服器 發布:2025-02-26 22:20:20 瀏覽:840
安卓轉蘋果怎麼搬家 發布:2025-02-26 22:09:55 瀏覽:333
830碼表怎麼設置自己ftp 發布:2025-02-26 21:43:05 瀏覽:537
java中級工程師面試題 發布:2025-02-26 21:41:18 瀏覽:660