Android 修改EditView输入框默认的光标颜色

前言

都知道Android原生的控件颜色比较辣眼睛,所以实际开发中都会有改动,所以我们今天来改一下输入框光标的默认颜色。
在drawble下面创建一个名为cursor_style.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="#4A90E2" />
</shape>

然后再布局文件中使用即可

			<EditText
                android:id="@+id/ed_pwd"
         		android:textCursorDrawable="@drawable/cursor_style"
                android:textColor="#000"
                android:textSize="@dimen/sp_24"
                android:paddingLeft="@dimen/dp_15"
                android:layout_width="wrap_content"
                android:layout_height="@dimen/dp_65"/>

然后就可以看到蓝色的光标了。

发布了33 篇原创文章 · 获赞 7 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_38436214/article/details/104778733
今日推荐