最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android開發(fā)手冊TextInputLayout樣式使用示例

 更新時間:2022年06月10日 17:22:39   作者:芝麻粒兒  
這篇文章主要為大家介紹了Android開發(fā)手冊TextInputLayout樣式使用示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

前言

前面小空帶同學們學了EditText控件,又用其實踐做了個驗證碼功能,以為這就完了嗎?

然而并沒有。

Android在5.0以后引入了Materia Design庫的設計,現(xiàn)在又有了Jetpack UI庫的設計。幫助開發(fā)者更高效的實現(xiàn)炫酷的UI界面,降低開發(fā)門檻。

Jetpack我們后面再說,承接之前的EditText,先說說Materia Design里的TextInputLayout。

使用方式是將TextInputEditText或EditText套到TextInputLayout內,這樣友情提示信息hit就可以帶有動畫(上浮為標題),計數(shù)/密碼可見等屬性設置。  

布局代碼

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="請輸入用戶名">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="number" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="60dp"
    android:hint="請輸入密碼">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>

這樣就簡單的實現(xiàn)了一個效果。我們在繼續(xù)深入添加些屬性:

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="請輸入用戶名"
    app:hintAnimationEnabled="false">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="number" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="60dp"
    android:hint="請輸入密碼"
    app:counterEnabled="true"
    app:counterMaxLength="10"
    app:passwordToggleEnabled="true">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>

從運行結果可以看出,設置了字數(shù)限制后,自動在編輯框右下角顯示最大字數(shù)和當前輸入字數(shù)(隨著輸入情況實時變化),并且更改了顏色樣式

??屬性介紹

  • app:boxCollapsedPaddingTop 設置用于編輯文本在框模式下折疊的頂部填充的值 
  • app:boxStrokeErrorColor 在顯示錯誤時設置輪廓框的描邊顏色。 
  • app:boxStrokeWidth 設置描邊的寬度 
  • app:boxStrokeWidthFocused 設置獲取焦點框的描邊寬度 
  • app:counterEnabled     是否顯示計數(shù)器 
  • app:counterMaxLength 設置計數(shù)器的最大值,與counterEnabled同時使用 
  • app:counterTextAppearance       計數(shù)器的字體樣式 
  • app:counterOverflowTextAppearance 輸入字符大于我們限定個數(shù)字符時的字體樣式 
  • app:errorEnabled  是否顯示錯誤信息 
  • app:errorTextAppearance&nbsp;   錯誤信息的字體樣式 
  • app:endIconCheckable 設置是否顯示結束圖標 
  • app:endIconContentDescription 為結束圖標設置內容說明 
  • app:endIconDrawable 設置結束圖標圖像 
  • app:endIconMode 設置模式 
  • app:endIconTintMode 指定混合模式,用于將 指定的色調應用于可繪制的結束圖標。 
  • app:helperText 設置幫助文本 
  • app:helperTextEnabled 設置是否激活幫助文本 
  • app:helperTextTextColor 設置幫助文本顏色 
  • app:hintAnimationEnabled  是否顯示hint的動畫,默認true 
  • app:hintEnabled    是否使用hint屬性,默認true 
  • app:hintTextAppearance      設置hint的文字樣式(指運行動畫效果之后的樣式) 
  • app:passwordToggleDrawable    設置密碼開關Drawable圖片,于passwordToggleEnabled同時使用 
  • app:passwordToggleEnabled      是否顯示密碼開關圖片,需要EditText設置inputType 
  • app:passwordToggleTint     設置密碼開關圖片顏色 
  • app:passwordToggleTintMode    設置密碼開關圖片(混合顏色模式),與passwordToggleTint同時使用

以上就是Android開發(fā)手冊TextInputLayout樣式使用示例的詳細內容,更多關于Android開發(fā)TextInputLayout樣式的資料請關注腳本之家其它相關文章!

相關文章

  • Android開發(fā)實現(xiàn)讀取Assets下文件及文件寫入存儲卡的方法

    Android開發(fā)實現(xiàn)讀取Assets下文件及文件寫入存儲卡的方法

    這篇文章主要介紹了Android開發(fā)實現(xiàn)讀取Assets下文件及文件寫入存儲卡的方法,涉及Android文件與目錄的讀取、寫入、轉換等相關操作技巧,需要的朋友可以參考下
    2017-10-10
  • android打開rar壓縮文件

    android打開rar壓縮文件

    這篇文章主要介紹了android打開rar壓縮文件示例,調用RAR for android 打開壓縮文件,需要的朋友可以參考下
    2014-03-03
  • Android使用OkHttp發(fā)送post請求

    Android使用OkHttp發(fā)送post請求

    這篇文章主要為大家詳細介紹了Android使用OkHttp發(fā)送post請求,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-11-11
  • Android Flutter表格組件Table的使用詳解

    Android Flutter表格組件Table的使用詳解

    Table組件不同于其它Flex布局,它是直接繼承的RenderObjectWidget的。本篇文章主要介紹如何在頁面中使用表格做一個記錄,感興趣的可以嘗試一下
    2022-06-06
  • 手機/移動前端開發(fā)需要注意的20個要點

    手機/移動前端開發(fā)需要注意的20個要點

    本文主要介紹了手機/移動前端開發(fā)需要注意的20個要點,具有很好的參考價值。下面跟著小編一起來看下吧
    2017-03-03
  • Android中主要資源文件及文件夾介紹

    Android中主要資源文件及文件夾介紹

    在Android項目文件夾里面,主要的資源文件是放在res文件夾里面的,下面為大家詳細介紹下各個資源文件的作用,感興趣的朋友可以參考下哈
    2013-06-06
  • Android 添加系統(tǒng)服務的方法詳解

    Android 添加系統(tǒng)服務的方法詳解

    這篇文章主要介紹了Android 添加系統(tǒng)服務的方法詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-02-02
  • Android數(shù)據(jù)存儲之SQLite使用

    Android數(shù)據(jù)存儲之SQLite使用

    SQLite是D.Richard Hipp用C語言編寫的開源嵌入式數(shù)據(jù)庫引擎。它支持大多數(shù)的SQL92標準,并且可以在所有主要的操作系統(tǒng)上運行
    2016-01-01
  • Android給任何view添加全屏傾斜水印

    Android給任何view添加全屏傾斜水印

    本篇文章主要介紹了Android給任何view添加全屏傾斜水印,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-10-10
  • Android手機獲取Mac地址的幾種方法

    Android手機獲取Mac地址的幾種方法

    今天小編就為大家分享一篇關于Android手機獲取Mac地址的幾種方法,小編覺得內容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-02-02

最新評論

新晃| 佛冈县| 固镇县| 大连市| 新乡市| 夏河县| 阜新市| 茶陵县| 广元市| 喀喇沁旗| 楚雄市| 大城县| 赫章县| 门头沟区| 普陀区| 买车| 北京市| 深水埗区| 海兴县| 彰武县| 东至县| 文山县| 馆陶县| 定日县| 合山市| 罗山县| 湖州市| 常山县| 饶河县| 成安县| 临洮县| 宝兴县| 乐平市| 灵石县| 三原县| 云浮市| 鞍山市| 台湾省| 利津县| 台北县| 沂南县|