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"/>

然後就可以看到藍色的光標了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章