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

前端之家收集整理的这篇文章主要介绍了在Android的所有sdk中更改EditText光标的颜色前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
想要更改 android的edittext光标颜色,这必须在所有设备上工作

解决方法

我不得不使用这样的drawable:

mycursor.xml:

@H_403_8@<?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>

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

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

猜你在找的Android相关文章