user1871869
user1871869

Reputation: 3367

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!

Upvotes: 1

Views: 1117

Answers (2)

Nisarg
Nisarg

Reputation: 1388

You can also try like this, by putting it below edittext

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

Upvotes: 0

Abhishek Patel
Abhishek Patel

Reputation: 4328

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"

Upvotes: 1

Related Questions