androidandroid-studioandroid-layoutandroid-edittext

Remove the underline when typing word in EditText


I know, the question has already been asked many times on this forum, but no answer worked for me... When I write in one of my EditTexts, the word being written is underlined, and I would like it not to be underlined... I've already seen answers like "You have to change the android:background", or "You have to put the textNoSuggestions attribute in android:inputType"... But I've already done all that - see the code just below - (and I even keep them by default) and it doesn't work.

A really huge thank you to everyone who will take the time to answer this question!

XML EditText :

<EditText
            android:id="@+id/editP1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_margin="4dp"
            android:autofillHints="username"
            android:background="@drawable/background_card"
            android:gravity="center_horizontal"
            android:hint="@string/player_name"
            android:imeOptions="flagNoFullscreen"
            android:inputType="textFilter|textNoSuggestions"
            android:maxLength="12"
            android:padding="4dp"
            android:textSize="25sp" />
<!-- The ' android:imeOptions = "flagNoFullscreen" ' was only necessary to show the underline word since my app is always in landscape mode -->

Pictures : The 2 EditTexts with one of them underligne to cursor.


Solution

  • As outlined at Android edittext is underlined when typing, this may be a function of the keyboard in use, rather than the EditText. Without knowing which specific solutions you've tried and have failed (you say no answer worked for you, but don't list things you tried) it is hard to offer a specific suggestion, but I'd suggest the

    android:inputType="textVisiblePassword|textNoSuggestions"
    

    option and see if that works. The password should typically prevent the keyboard from suggesting things (since no suggestions are typically useful for passwords).