Remove the underline from the edittext field in android xml

Hide disable EditText view below supporting line via activity_main.xml file.

EditText underline display just below of android editText view tag and its a simple blue color line that shows editText layout width. But some times developer wants to hide this underline so it can be done by layout file using android:background=”@null” attribute @null shows that there is no background required so please set all the filed background as empty. So here is the complete step by step tutorial for Remove the underline from the edittext field in android xml.

android-project-download-code-button

How to Remove the underline from the edittext field in android xml.

Code for MainActivity.java file.

package com.android_examples.com.edittextremoveunderline;
import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 }
}

Code for activity_main.xml layout file.

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context="com.android_examples.com.edittextremoveunderline.MainActivity" >

 <EditText
 android:id="@+id/editText1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_centerHorizontal="true"
 android:layout_centerVertical="true"
 android:ems="10"
 android:background="@null"
 android:hint="This is EditText." >

 <requestFocus />
 </EditText>

</RelativeLayout>

Screenshot:

Remove the underline from the edittext field in android xml

Click Here To Download Remove the underline from the edittext field in android xml project.

Leave a Reply

Your email address will not be published. Required fields are marked *