[英]Underline EditText Hint Text
Is it Possible to underline the hint text in Androids EditText ? 是否可以在Androids EditText中对提示文本加下划线? I want to underline the hint text and disable underline for the real text in my edit text.
我想在提示文本下划线,并在编辑文本中禁用真实文本的下划线。 Any suggestions?
有什么建议么?
You can set a charsequence programitically using FromHtml In that add 您可以使用FromHtml以编程方式设置字符序列 。
String str = "Start Text <u>Your Hind</U> End Test";
Or simply add a string in strings.xml 或者只是在strings.xml中添加一个字符串
"Start Text <u>Your Hind</U> End Test"
and set to EditText 并设置为EditText
See Sample Code 查看示例代码
<string name="str_hint">Hello <u>This is hello</u>world!</string>
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/textView1"
android:ems="10"
android:hint="@string/str_hint" />
setHint采用CharSequence,因此您可以向其发送带下划线的spannable,它应该可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.