1

How to change the android edittext cursor color with respect to background color of the android edittext(dynamically)?.If I choose dark background color for edittext, cursor would be light.If I choose dark background color for edittext, cursor would be dark.Based on edittext color change the cursor color will change at runtime.How to achieve this? any ideas welcome.

Harish Gyanani
  • 1,366
  • 2
  • 22
  • 43
karthi
  • 125
  • 2
  • 8

2 Answers2

1

try to add this attribute it will work android:textCursorDrawable

<  EditText   
android:layout_width="fill_parent"   
android:layout_height="wrap_content"  
android:textCursorDrawable="@drawable/color_cursor"  
/>
0
 Field f = null;
 f = TextView.class.getDeclaredField("mCursorDrawableRes");
 f.setAccessible(true);
 f.set(editText, R.drawable.color);
DoronK
  • 4,837
  • 2
  • 32
  • 37
  • What if we want to change pointer color? You can answer me here too http://stackoverflow.com/questions/41240065/edittext-cursor-and-pointer-color-for-below-android-5-0 – Harish Gyanani Dec 20 '16 at 10:53