更改 EditText 底部边框的大小 [英] Change Size of EditText bottom border

查看:15
本文介绍了更改 EditText 底部边框的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码中有一些 EditText,我想让它的底部边框更薄一些.在互联网上找不到任何关于它的信息,也许这里的任何人都可以帮助我.

I have some EditText in my code and I want to make the bottom border of it a bit thinner. Couldn't find anything about it in the Internet, maybe anyone here can help me with it.

我有什么:

我想要的:

推荐答案

像这样尝试焦点效果:

edt_bg_selector.xml:

edt_bg_selector.xml :

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

edt_bg_normal.xml:

edt_bg_normal.xml :

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:bottom="1dp"
    android:left="-2dp"
    android:right="-2dp"
    android:top="-2dp">
    <shape android:shape="rectangle" >
        <stroke
            android:width="1px"
            android:color="#FF000000" />

        <solid android:color="#00FFFFFF" />

        <padding
            android:bottom="5dp"
            android:left="5dp"
            android:right="5dp"
            android:top="5dp" />
    </shape>
</item>
</layer-list>

edt_bg_selected.xml:

edt_bg_selected.xml :

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:bottom="1dp"
    android:left="-2dp"
    android:right="-2dp"
    android:top="-2dp">
    <shape android:shape="rectangle" >
        <stroke
            android:width="1px"
            android:color="#ff0000" />

        <solid android:color="#00FFFFFF" />

        <padding
            android:bottom="5dp"
            android:left="5dp"
            android:right="5dp"
            android:top="5dp" />
    </shape>
</item>
</layer-list>

并更改您的编辑文本,例如:

and change your edit text like:

 <EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/edt_bg_selector" />

这篇关于更改 EditText 底部边框的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆