Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the border of edittextfield in android

How can I remove the border of a Edittext field in android. Actually it looks like this

http://pbrd.co/V34sN7

With this layout code

    <EditText
        android:id="@+id/login_error"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:background="@android:drawable/editbox_background_normal"
        android:visibility="invisible" 
        android:textColor="#FF0000"
        android:layout_gravity="right"
        />

Also the alignment of the text is not on the right side although I defined it.

Thanks

like image 486
Al Phaba Avatar asked Jan 07 '13 15:01

Al Phaba


4 Answers

Simply, You can use following in your xml file to make EditText background clear:

android:background="@null"
like image 121
uniruddh Avatar answered Dec 02 '22 04:12

uniruddh


Programmatic method:

setBackgroundDrawable(null);

Or, since setBackgroundDrawable() is deprectated in API 16:

if (Build.VERSION.SDK_INT >= 16)
    setBackground(null);
else
    setBackgroundDrawable(null);
like image 23
Sergey Galin Avatar answered Dec 02 '22 05:12

Sergey Galin


You can customize your EditText by using the following xml layout

Save the following code asyourWishName.xml

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

//You can change the color of the edit text here which removes the border line as well
 <item android:state_focused="true" >
    <shape android:shape="rectangle">
        <gradient
            android:startColor="#FFFFFF"
            android:endColor="#FFFFFF"
            android:angle="270" />
        <stroke
            android:width="3dp"
            android:color="#F8B334" />
        <corners
            android:radius="12dp" /> 
    </shape>
</item>  
<item>
    <shape android:shape="rectangle">
        <gradient
            android:startColor="#FFFFFF"
            android:endColor="#FFFFFF"
            android:angle="270" />
        <stroke
            android:width="0dp"
            android:color="#000000" />
        <corners
            android:radius="12dp" /> 
    </shape>
</item>
</selector>

In EditText call the xml android:background="@drawable/yourWishName"

To Align right Use android:gravity="right"

Hope this helps

like image 44
vinothp Avatar answered Dec 02 '22 06:12

vinothp


You have to create a custom drawable nine patch file which hasn't got a border. Here you find a tutorial And the android:layout_gravity="right" not means that the text is aligned to the right. It aligns the layout to the right. You have to use android:gravity="right".

like image 27
Tamás Cseh Avatar answered Dec 02 '22 05:12

Tamás Cseh