Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to programmatically set the color of Placeholder text of a disabled Entry on Andriod

$
0
0

Here Is The Custom Render In Xamarin forms Andriod.When the Entery is disable and its color convert to gray .and when i again enable the entry then the color of entry remain gray but entry is Enabled. How i can change color gray to black when entry is enable.

[assembly: ExportRenderer(typeof(CommaEntry), typeof(CommaEntryRenderer))]
namespace CancerPortal.Droid.CustomRenderers
{
    public class CommaEntryRenderer : EntryRenderer
    {
        public static void Init() { }
        private Android.Content.Context contxt = null;
        public CommaEntryRenderer(Context context) : base(context)
        {
            contxt = context;
        }
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement == null)
            {
                Control.Background = null;

                Control.SetHintTextColor(global::Android.Graphics.Color.Rgb(128, 128, 128));
                Control.Typeface = Android.Graphics.Typeface.CreateFromAsset(contxt.Assets, "Roboto-Regular.ttf");
                Control.TextSize = 16;
                var layoutParams = new MarginLayoutParams(Control.LayoutParameters);
                layoutParams.SetMargins(0, 0, 0, 0);
                LayoutParameters = layoutParams;
                Control.LayoutParameters = layoutParams;
                Control.SetPadding(24, 10, 24, 10);
                e.NewElement.Keyboard = Keyboard.Telephone;
                SetPadding(24, 10, 24, 10);
            }
            if (Control != null)
            {
                InputTypes its = InputTypes.ClassNumber | InputTypes.NumberFlagSigned | InputTypes.NumberFlagDecimal;
                Control.SetRawInputType(its);
                if (Control.Enabled == false)  
                {

                }
                else  ////enable status
                {
                 //  how i can change color of the text to black when entry is enable.
                }

            }
        }
    }
}

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>