Android(安卓)修改EditText的光标颜色和背景色
16lz
2021-12-04
Edittext 的光标颜色:
在xml布局文件中
android:textCursorDrawable=”@null” 表示光标的颜色和字体的颜色一样
当然,我们也可以自定义光标的颜色,在drawable文件夹下写个edit_cursor_color.xml文件
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <size android:width="2dp" /> <solid android:color="#ff7200" />shape>
然后 android:textCursorDrawable=”@drawable/edit_cursor_color”
Edittext 的背景颜色:
设置系统的 EditText 是一条下划线,自定义一条下划线的背景色
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <gradient android:endColor="#ff7200" android:startColor="#ff7200" /> shape> item> <item android:bottom="2dp"> <shape android:shape="rectangle" > <gradient android:endColor="#eeeeee" android:startColor="#eeeeee" /> shape> item>layer-list>
效果完全就是上图效果。
更多相关文章
- Android(安卓)EditText自动获取焦点并弹出软键盘,解决EditText在
- Fragment+viewpager 傻子都能看懂的demo 实例(博主就是个傻子)
- android shape总结 和控制的风格定制
- 取消默认Listview点击的显示的颜色
- android TextView的字体颜色设置的多种方法(续)
- android TextView的字体颜色设置的多种方法(续)
- android TextView的字体颜色设置的多种方法(续)
- android TextView的字体颜色设置的多种方法(续)
- Android隐藏ListView分割线