How to customize the underline of EditText
as shown below?
Asked
Active
Viewed 9,041 times
-1

K Neeraj Lal
- 6,768
- 3
- 24
- 33

Mithun Kumar
- 595
- 1
- 9
- 18
-
Picture could have been a bit smaller – Tim Sep 27 '16 at 08:46
-
Create a Drawable in XML and set as background of EditText. – D.J Sep 27 '16 at 08:47
-
Please google it before posting question.There are plenty of examples available.http://stackoverflow.com/questions/21480398/edittext-underline-below-text-property – kgandroid Sep 27 '16 at 08:55
1 Answers
4
You can do something like this
<EditText
android:id="@+id/editRemarks"
android:layout_below="@+id/addNoteRemarks"
android:gravity="left"
android:layout_centerHorizontal="true"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/edit_text_shape"/>
and below is the drawable file "edit_text_shape"
<?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 2dp width border around shape -->
<stroke
android:color="@color/viewfinder_laser"
android:width="2dp"
/>
</shape>
</item>
<!-- Overlap the left, top and right border using background color -->
<item
android:bottom="2dp"
>
<shape android:shape="rectangle">
<solid android:color="@color/white"/>
</shape>
</item>

Akash Dubey
- 1,508
- 17
- 34