更改光标一个EditText的颜色在Android中所有的SDK [英] Change the color of the cursor of an EditText in Android across all the sdk

查看:281
本文介绍了更改光标一个EditText的颜色在Android中所有的SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要改变Android的EditText上光标颜色,有跨越所有设备进行工作的。

Want to change the android's edittext cursor color, that has to be worked on across all the devices

推荐答案

我不得不使用一个绘制这样的:

i had to use a drawable like this:

mycursor.xml:

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>

在我编辑文本我这样设置光标绘制属性:

in my edit text i set the cursor drawable attributes like this:

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

这篇关于更改光标一个EditText的颜色在Android中所有的SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆