Android学习中,在EditText输入框中,取消下划线颜色和更换下划线的颜色

在EditText输入框中,取消下划线颜色和更换下划线的颜色

1.取消输入框中的样式

一般在我们所写出的EditText中,默认是有下划线,我们可以用下面这种方法取消

android:background="@null"

2.更换下划线的颜色

一般我们可以用background来更换背景色,button没有src属性,一般用background指定背景图或背景色,ImageView一般用src属性指定背景,ImageButton,一般用background指定背景图,但是我们在这里用background取消了背景色,所以此处我们需要从新写一个来更换下划线的颜色

 <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_below="@id/enterusername"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_toRightOf="@id/username"
        android:background="@color/btn_line"
        />

此处的background是调用了res目录下面的values下面的color.xml的内容

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="btn_line">#f76c03</color>
</resources>

整个页面的显示是

<TextView
        android:id="@+id/username"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="  "
        android:layout_marginTop="20dp"
        android:textSize="25sp"
        android:background="@drawable/icon_login_account"
        android:layout_marginLeft="@dimen/dp_20"
        />


    <EditText
        android:id="@+id/enterusername"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入登录账号"
        android:layout_toRightOf="@id/username"
        android:layout_alignBaseline="@id/username"
        android:layout_marginLeft="@dimen/dp_20"
        android:layout_marginRight="@dimen/dp_20"
        android:background="@null"
        />
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_below="@id/enterusername"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_toRightOf="@id/username"
        android:background="@color/btn_line"
        />

页面的显示为
在这里插入图片描述

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

胖胖IT

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值