解决android手机EditText设置光标颜色,android:textCursorDrawable="@drawable/corner_cursor" 华为手机无效果的问题

app开发,根据产品需求,需要修改输入框内,光标的颜色, 需要增加一个属性, 

android:textCursorDrawable="@drawable/corner_cursor"  

上完整的代码:

<EditText
    android:id="@+id/alertdialog_zhuan_zeng_friend_phone_Edt"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:textCursorDrawable="@drawable/corner_cursor"
    android:singleLine="true"
    android:maxLength="11"
    android:inputType="number"
    android:hint="手机号码"
    android:background="@color/color_F6F6F6"
    android:textColor="@color/color_666666"
    android:textSize="15sp" />

然后发现,大部分手机,光标颜色是变化为自己设置的颜色了的,但发现  华为手机  光标颜色还是系统自带颜色,设置的颜色无效果。经多次调试测试发现  需要在EditText里增加一个设置的属性,才会使 华为手机 的光标颜色生效: 代码是:  

android:imeOptions="normal"

修改后完整代码是:

<EditText
    android:id="@+id/alertdialog_zhuan_zeng_friend_phone_Edt"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:textCursorDrawable="@drawable/corner_cursor"
    android:imeOptions="normal"
    android:singleLine="true"
    android:maxLength="11"
    android:inputType="number"
    android:hint="手机号码"
    android:background="@color/color_F6F6F6"
    android:textColor="@color/color_666666"
    android:textSize="15sp" />

 

corner_cursor.xml文件代码( android:textCursorDrawable="@drawable/corner_cursor" ):
<?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="@color/color_FF5B00" />
</shape>

到此,设置输入框光标颜色,效果完美,完美解决  华为手机  设置输入框光标颜色不无效的问题。 

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yayayaiii

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值