如何删除从Android上的EditText领域的下划线?下划线、领域、Android、EditText

2023-09-06 13:33:46 作者:深海映星辰

每当一个字键入的的EditText中,我总是看到这个词在下划线被类型化。但是,当我preSS的空间这个词后,我再也看不到下划线。

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.

我reqirement是删除当用户键入消息下划线。

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.

下面是我使用的AlertDialog中的XML。

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>

推荐答案

您不必使用任何逻辑删除下划线 - 只需要调用的getText()的toString()当你要使用的值。它将不包括特殊格式或任何东西。

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.