android - 如何删除彩色 EditText 焦点边框

标签 android android-layout android-edittext focus

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

enter image description here

话虽如此,我已经在网上查看了它,以便删除 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"

关于android - 如何删除彩色 EditText 焦点边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37582503/

相关文章:

android - 更改 Realm 模型时出现 RealmMigrationNeededException

java - Android:使用 Gson 解析 JSON 文件时出错

android - 在 View 之间切换

android - Android 中的按钮动画

android - eclipse ADT 图形布局

java - Android Edittext行和字符限制

java - Android 库中的 Android NoClassDefFound

android - React Native 应用程序在启动第一个应用程序时显示一些错误

android - 在 EditText 字段中移动光标?安卓

android - 如何在 Activity 中使用 ScrollView 创建多行编辑文本?