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 http://forums.xamarin.com/discussion/comment/20938/#Comment_20938 and here http://stackoverflow.com/a/19796417/548975

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.

cheers

Posts

Sign In or Register to comment.