Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Custom controls renderer in Android (Entry etc) using C# or XML file in resources directory

$
0
0

Im new to xamarin forms android and trying to customise entry and few other controls (for now entry). Ive achieved my desired state with forms-iOS. However, I couldnt make it in android, even tried to add a xml file in Resources/Drawable directory, this gives an error.

In iOS

    [assembly: ExportRenderer (typeof (CustomEntry), typeof (CustomEntryRenderer))]
    namespace BarcodeScanner.iOS
    {
        public class CustomEntryRenderer: EntryRenderer
        {
            protected override void OnElementChanged (ElementChangedEventArgs<Entry> e)
            {
                base.OnElementChanged (e);

                if (Control != null) 
                {
                    Control.BorderStyle = UITextBorderStyle.None;
                    Control.Layer.BorderColor = UIColor.White.CGColor;
                    Control.Layer.BackgroundColor = UIColor.White.CGColor;
                    Control.Layer.BorderWidth = 1.0f;
                    Control.Font = UIFont.FromName ("AppleSDGothicNeo-Bold", 15f);
                    Control.Placeholder = "Enter text";
                    Control.TintColor = UIColor.Black;
                    Control.TextColor = UIColor.Black;
                    Control.ReturnKeyType = UIReturnKeyType.Search;
                }
            }
        }
    }

How could I achieve this in my android project??


Viewing all articles
Browse latest Browse all 58056

Trending Articles