如何删除彩色 EditText 焦点边框

How to remove colored EditText focus border

我想删除 EditText 底部的 EditText 焦点边框。我想要这样我的 EditText 看起来像这样:

话虽这么说,我已经在网上查看了它,以便删除 EditText 的底部焦点颜色尝试将我的 EditText 设置为 android:background="#00000000" 并且 android:background="@android:drawable/editbox_background_normal"。但是,hte 首先隐藏了整个下划线边框(我只想隐藏焦点下划线颜色,而不是下划线本身),后者使我的 EditText 变成一个大白框。有什么办法可以复制我上面想要的东西吗?谢谢!

试试这个

edittext_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="rectangle">
        <!-- Draw a 1dp width border around shape -->
        <stroke
            android:color="#d3d3d3"
            android:width="1dp"
            />
    </shape>
</item>
<!-- Draw only bottom border using background color  -->
<item
    android:bottom="1dp"
    >
    <shape android:shape="rectangle">
        <solid android:color="#ffffff"/>
    </shape>
</item>
</layer-list>

并将背景应用于您的 EditText

android:background="@drawable/edittext_bg"

你也可以这样试试,把它放在edittext下面

 <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@android:color/black" />