user1871869 user1871869 - 6 months ago 119
Android Question

How to remove colored EditText focus border

I wanted to remove the bottom

EditText
focus border on my
EditText
. I want it so that my
EditText
looks something like this:

enter image description here

That being said, I have looked online to make it so that the bottom focus color of the
EditText
is removed tried to set my
EditText
to
android:background="#00000000"
and also
android:background="@android:drawable/editbox_background_normal"
. However, hte first hides the entire underline border (which I only want to hide the focus underline color, not the underline itself) and the latter makes my
EditText
a big white box. Is there any way to replicate what I want above? Thanks!

Answer

Try This

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>

and apply background to Your EditText like

android:background="@drawable/edittext_bg"