Editext cursor color change in API 12

I tried to adjust the android edittext cursor. I found many solutions 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 this from API 8. So can I change the color of the edittext cursor in <API 12?

+6
source share
1 answer

You can 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) {} 

link: How to change the program color of the Edittext cursor in android?

+1
source

Source: https://habr.com/ru/post/952257/


All Articles