We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfAutoComplete > Custom Renderer - Cursor Color not working (OnElementChanged)

Thread ID:





148877 Nov 6,2019 10:10 PM UTC Mar 11,2020 02:30 PM UTC Xamarin.Forms 9
Tags: SfAutoComplete
Johannes Meyer
Asked On November 6, 2019 10:12 PM UTC

Hello ,

i use this code

using Syncfusion.SfAutoComplete.XForms;
using Syncfusion.SfAutoComplete.XForms.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

'[assembly: ExportRenderer(typeof(SfAutoCompleteExt), typeof(CustomAutocompleteRenderer))]
namespace xxxx.iOS.Renderers
    public class CustomAutocompleteRenderer : SfAutoCompleteRenderer
        protected override void OnElementChanged(ElementChangedEventArgs e)

            Control.TintColor = UIColor.Purple;


    public class SfAutoCompleteExt : SfAutoComplete

screenshot color is not changed on IOS simulator.

cursor color

Hemalatha Marikumar [Syncfusion]
Replied On November 7, 2019 07:35 AM UTC

Hi Johannes,

Greetings from Syncfusion.

We have prepared the sample with the provided code snippet and we are afraid that we are not able to reproduce the issue from our side. Please download the tested sample in below
Simulator version: iPhone 11 iOS 13 

Please check with the above sample and if the issue still reproduces from your side please modify the issue reproducing sample and provide the simulator details which will be helpful for us to analyze further and provide an appropriate solution.
Hemalatha M. 

Radoslaw Kubas
Replied On November 7, 2019 09:58 AM UTC


Could you provider similar sample for Android?

Best regards,

Hemalatha Marikumar [Syncfusion]
Replied On November 8, 2019 08:59 AM UTC

Hi Johannes, 
Thanks for your update. 
Your requirement “Change the color of cursor in SfAutoComplete in Android” has been achieved by setting the desired drawable (with desired color) to CursorDrawable of SfAutoComplete in Android as per in below code snippet. 
Codesnippet [C#]: 
  protected override void OnElementChanged(ElementChangedEventArgs<Syncfusion.SfAutoComplete.XForms.SfAutoComplete> e) 
            if (Control != null) 
                IntPtr IntPtrtextViewClass = JNIEnv.FindClass(typeof(TextView)); 
                IntPtr mCursorDrawableResProperty = JNIEnv.GetFieldID(IntPtrtextViewClass, "mCursorDrawableRes", "I"); 
                JNIEnv.SetField(Control.GetAutoEditText().Handle, mCursorDrawableResProperty, Resource.Drawable.my_cursor); 
Codesnippet [xml]: (EntryCursorDemo.Android/Resources/drawable/my_cursor.xml) 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
  <solid android:color="@color/colorCursors"></solid> 
  <size android:width="2dp" /> 
Note: colorCursors key holds #800090 color and its path file (EntryCursorDemo.Android/Resources/values/colors.xml) 
We have prepared the sample using Custom Renderer for Android. Please have the sample from the below link,

Sample Link:  https://www.syncfusion.com/downloads/support/directtrac/general/ze/ENTRYC~1-119617468



Please check with the above sample and let us know if you have any concerns.
Hemalatha M. 

Johannes Meyer
Replied On November 8, 2019 09:49 AM UTC

thanks for your help ;)

Hemalatha Marikumar [Syncfusion]
Replied On November 11, 2019 05:30 AM UTC

Hi Johannes, 
Thanks for you update. 
Please let us know if you have any other query. 
Hemalatha M. 

Eric Oudin
Replied On February 27, 2020 09:39 PM UTC

How would you change the color after it has been initialized?
 An example would be change theme. Select inside entry you see it looks correct. Change theme again. Select inside entry and it stays the color that it was initialized as from whenever you first selected the box. Running the same code to change the color will no longer work on the same entry once it has been drawn tot he screen once before.

I am also curious where I would find a list of drawable property names. I was able to find the cursor color from some googling but why isnt there documentation on other properties i can edit colors of the same way?

                    IntPtr mCursorDrawableResProperty = JNIEnv.GetFieldID(IntPtrtextViewClass, "mCursorDrawableRes", "I");

as an example the second parameter for that function... Where is that name coming from?

Most of all, why cant I just set it to a color I have dynamically?

Anandraj Selvam [Syncfusion]
Replied On March 2, 2020 12:31 PM UTC

Hi Eric Oudin,   
Thanks for the update,   
Currently, we are validating the reported issue and we will update you on the complete status on 4th March 2020.   
Anand Raj S.  

Anandraj Selvam [Syncfusion]
Replied On March 5, 2020 05:50 PM UTC

Hi Eric Oudin,    
Thanks for your patience,    
We are still validating the reported issue with high priority and we will update you on the complete status on or before 10th March 2020.    
We appreciate your patience until then. 
Anand Raj S.   

Anandraj Selvam [Syncfusion]
Replied On March 11, 2020 02:30 PM UTC

Hi Eric, 
Thanks for your patience. 
On further analysis on your query, we cannot change the cursor color dynamically using drawble in Android platform. But you can change the color before the cursor drawn into the screen dynamically. We have created sample to change the cursor color before cursor drawn into screen in button click using dependecy service.Please find the sample from below link 
Please get back us, if you have any concern. 
Anand Raj S.  


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon