如何在 EditText 中隐藏下划线 [英] How to hide underbar in EditText

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

问题描述

如何隐藏 EditText 下栏(末尾带有小衬线的提示行)?

How can I hide the EditText underbar (the prompt line with little serifs at the ends)?

可能有更好的方法来做我想做的事:我有一个带有 EditText 的布局.通常,在用户可以点击它并开始输入或编辑文本的地方显示良好.

There might be a better way to do what I want: I have a layout with an EditText. Normally, this displays fine where the user can tap on it and begin entering or editing text.

不过,有时我想使用相同的布局(简化其他逻辑)以只读方式显示相同的数据.我希望演示文稿相似 - 它应该具有相同的高度和相同的字体,但没有下划线.

Sometimes, however, I would like to use the same layout (simplifies other logic) to display the same data in a read-only manner. I want the presentation to be similar - it should have the same height and same font, but not have the underbar.

作为权宜之计,我将通过删除 EditText 并替换为 TextView 来实现这一点.我认为这会产生预期的结果,但它似乎是一种迂回的方式,是一种昂贵的方式来做一些应该很容易通过改变属性来完成的事情.

As a stop-gap measure, I'm going to implement this by removing the EditText and substituting a TextView. I think that will give the desired results, but it seems like a roundabout an expensive way to do something that ought to be easy to do by changing attributes.

推荐答案

您可以将 EditText 设置为具有自定义透明可绘制对象或仅使用

You can set the EditText to have a custom transparent drawable or just use

android:background="@android:color/transparent"

android:background="@null"

或以编程方式

editText.setBackgroundResource(android.R.color.transparent);

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

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