Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the underline from the EditText field in Android?

Whenever a word is typed in the EditText box, I always see an underline under the word being typed. But when I press a space after that word I no longer see the underline.

My reqirement is to remove that underline when the user is typing the message.

Added is the screenshot and we see that Smith is underlined. But I don't want this to happen.

Below is the xml that I use for the AlertDialog box.

<?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="wrap_content"
android:orientation="vertical">

<TextView 
    android:id="@+id/name_view"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_marginLeft="20dip"
    android:layout_marginRight="20dip"
    android:text="@string/alert_dialog_name"
    android:gravity="left"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<EditText
    android:id="@+id/username_edit"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:layout_marginLeft="20dip"
    android:layout_marginRight="20dip"
    android:scrollHorizontally="true"
    android:autoText="false"
    android:inputType="textPersonName"
    android:capitalize="none"
    android:gravity="fill_horizontal"
    android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>

enter image description here

like image 242
Sana Avatar asked Mar 31 '11 18:03

Sana


People also ask

How do I get rid of TextInputLayout bottom line?

in the TextInputLayout, set app:boxStrokeWidth="0dp" in the TextInputEditText, set app:boxBackgroundColor="@color/white" . it worked for me when my background is white.

What is TextInputLayout?

TextInputLayout is a view container that is used to add more features to an EditText. It acts as a wrapper for EditText and has some features like: Floating hint. Animation that can be disabled or enabled. Error labels that display error messages when an error occurs.


3 Answers

android:inputType="textNoSuggestions"

like image 61
sgibly Avatar answered Oct 16 '22 17:10

sgibly


There is a function that removes any composing state. I think if you call it after every time a user types, you will not see the underline. I use it after the user finishes typing, to get the drawing cache of the entire textView (which I need without underline). It's

someTextView.clearComposingText();
like image 21
n00b programmer Avatar answered Oct 16 '22 18:10

n00b programmer


You don't have to use any logic to remove the underlines -- just call getText().toString() when you want to use the value. It won't include special formatting or anything.

like image 12
Yoni Samlan Avatar answered Oct 16 '22 19:10

Yoni Samlan