Is it Possible to underline the hint text in 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
String str = "Start Text <u>Your Hind</U> End Test";
Or simply add a string in strings.xml
"Start Text <u>Your Hind</U> End Test"
and set to 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,它应该可以正常工作。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.