Forum Xamarin Xamarin.Forms

xamarin forms android invisible cursor / missing caret on android versions (it's white)

Shane000Shane000 USMember ✭✭✭
edited April 2015 in Xamarin.Forms

To fix this in a custom renderer I had to use reflection and it took awhile so here is the fix:

IntPtrtextViewClass = JNIEnv.FindClass(typeof(TextView));
IntPtr mCursorDrawableResProperty = JNIEnv.GetFieldID (textViewClass, "mCursorDrawableRes", "I");
JNIEnv.SetField (Control.Handle, mCursorDrawableResProperty, 0);

(Control is the EditText control in the custom renderer)

adapted from here and here

This lets you turn the android:textCursorDrawable to null so you can see the cursor again. (In my case it was due to a white cursor on a white background in some versions of android.



Sign In or Register to comment.