如何从 Android 中的 EditText 字段中删除下划线? [英] How to remove the underline from the EditText field in Android?

查看:36
本文介绍了如何从 Android 中的 EditText 字段中删除下划线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当在 EditText 框中键入一个单词时,我总是会在正在键入的单词下方看到一个下划线.但是当我在那个词后面按一个空格时,我不再看到下划线.

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.

添加了屏幕截图,我们看到 Smith 带有下划线.但我不希望这种情况发生.

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

下面是我用于警报对话框的 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.

这篇关于如何从 Android 中的 EditText 字段中删除下划线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆