Android 给TextView控件设置下划线

首先,我们先看一下效果

如上图所看到的那样,在“全部提现”加上一个下划线,

那么,我们先来看下我们的TextView控件:

 <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:autoLink="all"
            android:background="@drawable/tomoney_line"
            android:text="全部提现"
            android:textColor="@color/red_ff"
            android:textSize="11dp" />

在这段代码中,我们会看到我们经常用的一个属性:background,没错就是它,像咱们以往的操作一样,创建一个资源文件,附上代码:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 边框颜色值 -->
    <item>
        <shape>
            <solid android:color="@color/red_ff" /><!--下划线颜色-->
        </shape>
    </item>
    <item android:bottom="1dp"> <!--下划线厚度-->
        <shape>
            <solid android:color="@color/white" /><!--背景色 不能透明否则会显示上面的下划线颜色-->
        </shape>
    </item>
</layer-list>

在注释地方,还上自己的需求即可。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值