因为有些时候我们为了保持APP风格一致,需要更改原生EditText的底线颜色。特此记录一种简单的方法。
效果图
默认的 EditText 底线颜色 是红色的:
我们 想 实现 蓝色的 效果:
实现方法
Edit text去除边框
android:background="@null"
这句代码可以去掉 edittext 的边框
Edit text底部加线
在 drawable 新建一个 line.xml
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#00f"/> <size android:height="2dp" android:width="1000dp" />shape>
在 layout 的布局文件中 引用
android:id="@+id/editText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@null" android:drawableBottom="@drawable/line" />
这样就可以了,还有一种方法是准备一个背景图直接替换掉就可以实现。好了,拜拜!