欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android開發(fā)中自定義 editText下劃線

 更新時(shí)間:2023年03月08日 08:15:26   作者:xwg11  
這篇文章主要介紹了Android開發(fā)中自定義 editText下劃線的相關(guān)資料,需要的朋友可以參考下

看了下網(wǎng)上代碼:

我想要的效果如下圖

自定義 editText下劃線_下劃線

下劃線和文字有15dp的間距   eeeeee的顏色

上代碼,

<"1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
            android:bottom="0dp"
            android:left="-1dp"
            android:right="-1dp"
            android:top="-1dp">
        <shape>
            <solid android:color="@android:color/transparent" />
            <stroke      android:color="@color/color_eeeeee"
                         android:width="1dp" />
            <padding android:bottom="15dp" />

        </shape>
    </item>

</layer-list>

那么 就會(huì)變成4邊都有邊框包裹,這里設(shè)置-1dp 是抹去不想顯示的邊框,因?yàn)橹恍枰聞澗€  ,所以上下左全部設(shè)置成-1dp,

shape中的 stroke  中  2個(gè)屬性 ,一個(gè)是color  表示邊框的顏色,width表示邊框的寬度。我這里設(shè)置1DP

需求是文字與下劃線間隔15DP  ,那么就在<padding 中設(shè)置bottom 為15dp。

再寫個(gè)selector  就可以用了

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="false" android:drawable="@drawable/et_underline_selected"/>
    <item android:state_focused="true" android:drawable="@drawable/et_underline_selected"/>
</selector>

然后把這個(gè)樣式設(shè)置成edittext的默認(rèn)樣式,以后就不用每次都調(diào)用這個(gè)了

具體操作如下

現(xiàn)在androidManifest中找到你系統(tǒng)的樣式

自定義 editText下劃線_下劃線_02

自定義 editText下劃線_下劃線_03

到此這篇關(guān)于Android開發(fā)中自定義 editText下劃線的文章就介紹到這了,更多相關(guān)自定義 editText下劃線內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論