您好,欢迎来到伴沃教育。
搜索
您的当前位置:首页修改EditText光标颜色

修改EditText光标颜色

来源:伴沃教育

1.自定义shape文件

<?xml version="1.0" encoding="utf-8"?>
<shape 
    android:shape="rectangle">
    <size android:width="2dp" />
    <solid android:color="@color/color_login_btn_bg_normal" />
</shape>

2.设置android:textCursorDrawable

     <EditText
            android:id="@+id/login_username_et"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@null"
            android:hint="用户名称"
            android:inputType="text"
            android:maxLength="25"
            android:singleLine="true"
            android:textCursorDrawable="@drawable/shape_login_color_cursor"
            android:textSize="16sp" />

设置好效果:


这里写图片描述

Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务