最近在项目中正好碰到需求:给文字实现下划线的效果,在网上搜索了下,有提供方法,但是我想完全依靠xml布局去实现,然后试验了几次,最终只用了TextView做出了如下效果:
下划线图片代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#0042F4" />
<size android:height="2dp"
android:width="90dp"/>
</shape>
现在看TextView的设置:
?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width=