Reputation: 125
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.
Upvotes: 1
Views: 1042
Reputation: 4837
Field f = null;
f = TextView.class.getDeclaredField("mCursorDrawableRes");
f.setAccessible(true);
f.set(editText, R.drawable.color);
Upvotes: 0
Reputation:
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"
/>
Upvotes: 1