I have a Xamarin Forms Android application with the Material Design Visual. That seems to override the cursor color to black. Now I would like to create a dark theme. On IOS the cursor color changes with the font color to white. But on Android it stays black which makes it barely visible. Is there a way that I can override the color set as the cursor color?
Based on this Forum discussion I tried this Effect: https://forums.xamarin.com/discussion/42823/change-entry-cursor
protected override void OnAttached()
{
try
{
IntPtr IntPtrtextViewClass = JNIEnv.FindClass(typeof(TextView));
IntPtr mCursorDrawableResProperty = JNIEnv.GetFieldID(IntPtrtextViewClass, "mCursorDrawableRes", "I");
JNIEnv.SetField(Control.Handle, mCursorDrawableResProperty, Resource.Drawable.custom_cursor);
}
catch (Exception e) {
Console.WriteLine(e);
}
}
cursor drawable:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorAccent"></solid>
<size android:width="2dp" />
</shape>
But with that the app crashes with the following error in the output:
JNI DETECTED ERROR IN APPLICATION: jfieldID int android.widget.TextView.mCursorDrawableRes not valid for an object of class md5a6256f8d5bc17d3565a450e514d4a6e7.MaterialFormsTextInputLayout