微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Android的所有sdk中更改EditText光标的颜色

想要更改 android的edittext光标颜色,这必须在所有设备上工作

解决方法

我不得不使用这样的drawable:

mycursor.xml:

<?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
        <size android:width="1dp" />
        <solid android:color="@android:color/holo_blue_light"/> 
<!--make sure its a solid tag not stroke or it wont work -->
    </shape>

在我的编辑文本中,我设置了这样的游标可绘制属性

<EditText
                            android:id="@+id/et_details"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:cursorVisible="true"
                           android:textCursorDrawable="@drawable/mycursor"  
                            />

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐