I was trying to customize Android edittext
cursor. I found many solution using android:textCursorDrawable=""
on Google and StackOverflow. But it is available from API 12.
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="Android"
android:textCursorDrawable="@drawable/my_cursor_drawable" />
I want to do that from API 8. So is it possible to change edittext
cursor color in < API 12 ?
Custom cursor color EditText has an attribute: android:textCursorDrawable, which is used to set the cursor style.
You could try this(with java reflection),
try {
Field f = TextView.class.getDeclaredField("mCursorDrawableRes");
f.setAccessible(true);
f.set(et1, R.drawable.ic_launcher);
} catch (Exception ignored) {}
reference :How to Change programatically Edittext Cursor Color in android?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With