Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change focus color of Entry control in Xamarin Forms

How can you change the focus border and cursor color in a Entry control in Xamarin forms? In the emulator it is standard red?

I added this in my Android project

[assembly: ExportRenderer(typeof(CustomEntryControl), typeof(MyEntryRenderer))]
namespace MyApp.Droid
{
    public class MyEntryRenderer : EntryRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.SetBackgroundColor(global::Android.Graphics.Color.LightGreen);
            }
        }
    }
}

But can't find the property for border or cursor?

enter image description here

like image 635
user7849697 Avatar asked Dec 02 '25 23:12

user7849697


1 Answers

You can change Entry focus color in Android Project in the style.xml file. The path is: Resources/values/styles.xml

Then, look at the "colorAccent" property to set the custom color.

ColorAccent in Xamarin Android Project

like image 96
Eldlabs Avatar answered Dec 05 '25 14:12

Eldlabs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!