1.修改光标颜色
EditText有一个属性:android:textCursorDrawable,这个属性是用来控制光标颜色的android:textCursorDrawable="@null","@null"作用是让光标颜色和text color一样
自定义样式:
<1>在资源文件drawable下新建一个光标控制color_cursor.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <size android:width="1dp"/> <solid android:color="#f00"/> </shape>
<2>设置EditText:android:textCursorDrawable="@drawable/color_cursor"
2.修改底线颜色:
<1>自定义样式:在资源文件drawable下新建一个光标控制backgroup_cursor.xml
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <gradient android:endColor="#ff7200" android:startColor="#ff7200" /> </shape> </item> <item android:bottom="2dp"> <shape android:shape="rectangle" > <gradient android:endColor="#ffffff" android:startColor="#ffffff" /> </shape> </item> </layer-list>
<2>设置EditText属性:android:background="@drawable/backgroup_cusor"