用的EditText非可选变灰preFIX [英] EditText with non-selectable grayed out prefix

查看:213
本文介绍了用的EditText非可选变灰preFIX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方式有一个变灰的文本作为一个EditText preFIX。这段文字应该是不可选。
这是一个有点像要在您撰写与Gmail的信息中。唯一的(视觉)不同的是,当你开始输入该文本将消失。

I'm looking for a way to have a grayed out text as prefix in an EditText. This text should be not selectable. It's a bit like the To field when you're composing a message with Gmail. The only (visual) difference is that this text disappears when you start typing.

有什么诀窍在Android中实现这一目标?

Is there any trick to achieve this in Android?

谢谢!

推荐答案

作为一个最终的解决方案,您可以通过扩展它在某种程度上,它具有自定义背景被设置修改它改写了充分的EditText类,一predefined填充您所设定。

As an ultimate solution, you can rewrite the full EditText class by extending it and modifying it in a way that it has a custom Background set by you, and a predefined padding set by you.

把欧元为背景,在左侧定位,然后,得到的EditText的起始填充在这样一种方式,文中的用户类型,启动欧元文本之后

Put the EUR as the background, positioning it in the left side, and then give the starting padding of the EditText in such a way that the text the user types, starts right after the EUR text.

这也许算是一个矫枉过正或-穷人的解决了这个问题,但仍然是其最终的选择。不是最聪明的一个部分可能是,我也不知道它肯定会工作:P

This maybe regarded as an overkill or a poor-man's solution to this problem, but still its the ultimate option. Not the smartest one perhaps, and I also don't know if its gonna work for sure :P

所有最优秀的!

这篇关于用的EditText非可选变灰preFIX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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