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

查看:337
本文介绍了如何在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来实现此目的.我认为这样可以达到预期的效果,但是通过更改属性来完成某件事应该是一件容易的事,这似乎是一种round回的昂贵方法.

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天全站免登陆