Zero

Android修改EditText下划线线颜色

利用xml 画线

首先,将edittext 去除边框

android:background=”@null”

这个代码可以去掉 edittext 的边框

然后,edittext 底部加线

在drawable 新建一个 line.xml

1
2
3
4
5
6
7
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@color/orange_normal" />
<size
android:height="1dp"
android:width="1000dp" />
</shape>

最后,在layout 的布局文件中引用

<EditText
 android:id="@+id/phone"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="@null"
 android:drawableBottom="@drawable/line"
 android:hint="@string/phone_hint"
 android:inputType="phone"
 android:maxLength="11"
 android:maxLines="1" />