TextView、Button控件文本添加下划线最简单的方式就是在strings.xml资源文件中定义html格式的字符串,亦即添加<u>标签。
layout布局文件中:
<TextView
android:id="@+id/txt_underline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/underline"
android:textColor="#FFE5E5E5"
android:textSize="20sp" />
strings.xml资源文件中:
<string name="underline"><u>下划线测试</u></string>
注:必须在strings.xml文件中定义,在layout布局文件中直接添加<u>标签会出现编译错误。