Android如何更改edittext光标样式

问题描述:

我想定制EditText滑块样式。看到我下面的截图。Android如何更改edittext光标样式

这是默认的滑盖造型:

This is the default cursor Style

这是我希望看到的:

This is the cursor style I want to customize.

这可能是一个愚蠢的问题,但几个小时后,谷歌搜索,我只能找到更改光标颜色的方法,但找不到更改滑块样式的方法。

这是我使用用于改变光标颜色(color_cursor.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="#008000" /> 
</shape> 

我施加的 “机器人:textCursorDrawable =” @绘制/ color_cursor”到的EditText

感谢

+0

检查了这个光标是在材料设计库中可用http://*.com/questions/6225995/can-i-change-the-cursor-size-in-android-edit-text-field –

+1

。将您的EditText包装在TextInputLayout中。 – Emil

+0

你可以试试android:textCursorDrawable(...) – GiapLee

为自己的答案(希望这也将帮助他人): 介绍“Theme.material”后,将的EditText成为预期的风格,我会はnt查看材料设计

android:textSelectHandle="@drawable/your_desired_drawable" 

把它放在editText视图中。设置你喜欢的drawable。然后更改可绘制xml文件中的颜色。