how to remove border of edittext field

Viewed 27483

I have created a login layout but in this layout edittext field border is overlap. I want to remove the top border of second edit text field. please guide me. here is the link screen

I want to make layout exactly like this. Here is my XML code.

round_edittext.xml:

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

    <solid android:color="#FFFFFF" />

    <stroke
        android:width="1dp"
        android:color="#9999" />

    <corners
        android:bottomLeftRadius="1dp"
        android:bottomRightRadius="1dp"
        android:topLeftRadius="1dp"
        android:topRightRadius="1dp" />

</shape>

activity_mail.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <ImageButton
        android:id="@+id/save"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#00000000"
        android:clickable="false"
        android:src="@drawable/no_smslogo_text" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="40sp"
        android:layout_marginRight="40sp"
        android:layout_marginTop="10sp"
        android:background="@drawable/round_edittext"
        android:drawableLeft="@drawable/mobile_icon"
        android:drawablePadding="5dp"
        android:gravity="left"
        android:hint="Mobile Number"
        android:padding="5dp"
        android:paddingBottom="8sp"
        android:paddingTop="8sp"
        android:textSize="15dp" >
    </EditText>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="40sp"
        android:layout_marginRight="40sp"
        android:background="@drawable/round_edittext"
        android:drawable="@drawable/pin_icon"
        android:drawableLeft="@drawable/mobile_icon"
        android:drawablePadding="5dp"
        android:gravity="left"
        android:hint="Pin Number"
        android:padding="5dp"
        android:paddingBottom="8sp"
        android:paddingTop="8sp"
        android:textSize="15dp" />

    <Button
        android:id="@+id/signin"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="40sp"
        android:layout_marginRight="40sp"
        android:layout_marginTop="10sp"
        android:clickable="true"
        android:gravity="center"
        android:text="Sign In"
        android:textColor="#ffffff"
        android:textSize="15dp" />

</LinearLayout>
8 Answers

I did it by keeping the background transparent like this:

<EditText
    android:background="@android:color/transparent"
/>

use this::

              <EditText
                android:layout_width="200dp"
                android:layout_height="40dp"
                android:layout_marginStart="16dp"
                android:background="#00000000"
                android:hint="Username"
                />

There are two ways to go about this:

One is by adding a custom background to the editText using

 android:background="@drawable/customBackground

or by setting the background as transparent

android:background="@android:color/transparent"

I would suggest to use the first way if you want to further customize your view background instead of just removing it. Custom shape drawables are easy to create and apply to the view through XML or programatically.

Related