Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how add a border only on bottom of EditText?

Tags:

android

I saw many related discussions but didn't find a suitable solution. What I need to do is to create a black border on the bottom side of an EditText widget. Is that possible?

like image 324
Manjeet Brar Avatar asked Aug 25 '14 07:08

Manjeet Brar


People also ask

How do you add a border to EditText?

Create EditText with rounded corners border. EditText can be easily modified through activity_main. xml file via adding another layout file and set that rounded_border_edittext. xml file to editText background. This type of editText looks like most of web sites applications data submission forms.

How do you add a line to the bottom of a TextView?

setBackgroundResource(R. layout. border); This will make a black line on top and bottom of the TextView.

How do you make a white line in EditText?

Show activity on this post. To change Edittext's underline color: Then change the “colorAccent” to whatever the color you want your EditText line color to be.

How do you make EditText Uneditable?

In your xml code set focusable="false" , android:clickable="false" and android:cursorVisible="false" and this will make your EditText treat like non editable.


2 Answers

simple create one edittext_bottom_line.xml file in drawable folder in res

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:bottom="1dp"
        android:left="-2dp"
        android:right="-2dp"
        android:top="-2dp">
        <shape android:shape="rectangle" >
            <stroke
                android:width="0.5dp"
                android:color="@android:color/black" />
        </shape>
    </item>

</layer-list>

To set control's single property like these:

 <EditText
     android:id="@+id/editTextEnterPassword"
     android:layout_width="fill_parent"
     android:layout_height="40dp"
    android:background="@drawable/edittext_bottom_line"
    /> 
like image 73
Dhruv Raval Avatar answered Sep 21 '22 13:09

Dhruv Raval


just add underlinebg.xml in res/drawable

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:bottom="-1dp"
        android:left="-2dp"
        android:right="-2dp"
        android:top="-2dp">
        <shape android:shape="rectangle" >
            <stroke
                android:width="2dp"
                android:color="@color/drawe_content_color_click" />
        </shape>
    </item>

</layer-list> 

and set the background where ever required. For me i got the solution like [![myoutput!!][1]][1] .I think my answer will helpful for others.

like image 24
Subhalaxmi Avatar answered Sep 19 '22 13:09

Subhalaxmi