【问题标题】:How to change edit text cursor color and width in android如何在android中更改编辑文本光标的颜色和宽度
【发布时间】:2015-05-22 11:34:34
【问题描述】:

我正在开发一个新的应用程序,我需要自定义 EditText 光标颜色和光标宽度。任何人都可以指导我。这将是可观的。 提前致谢。

【问题讨论】:

标签: android


【解决方案1】:

为光标构建新的可绘制对象,例如在可绘制文件夹中将其命名为 my_custom_cursor_drawable.xml

my_custom_cursor_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"     android:shape="rectangle" >
<size android:width="0.5dp" />
<solid android:color="#FF0910DD"/>!--Could be any color you want
</shape>

您希望此自定义光标所在的 EditBox 将属性设置为

 android:textCursorDrawable="@drawable/cursor_drawable"

就是这样!!必要时即兴创作。任何可绘制,任何形状等......

【讨论】:

    【解决方案2】:

    您可以为 EditText 光标定义自定义可绘制对象,并使用 android:textCursorDrawable 将其用于 EditText。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 2012-12-26
      • 2015-08-15
      • 1970-01-01
      • 2012-01-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多