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>

效果完全就是上图效果。

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐