在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"
/>
页面的显示为