I have my CustomPicker.Please tell me how I can change the line`s color in Picker window

            Asked
            
        
        
            Active
            
        
            Viewed 994 times
        
    2
            
            
        
        Maria Kamenskyh
        
- 467
 - 1
 - 3
 - 21
 
- 
                    Does this answer your question? [Is it possible to change the colour of the line below / Border of a TextBox (Entry)](https://stackoverflow.com/questions/38207168/is-it-possible-to-change-the-colour-of-the-line-below-border-of-a-textbox-ent) – Óscar López Aug 24 '20 at 12:21
 
1 Answers
2
            You could implement it by using reflection .
private void setNumberPickerDividerColor(TextColorNumberPicker numberPicker)
    {
        TextColorNumberPicker picker = numberPicker;
        Java.Lang.Reflect.Field[] pickerFields = 
        Java.Lang.Class.FromType(typeof(NumberPicker)).GetDeclaredFields();
        foreach (Java.Lang.Reflect.Field pf in pickerFields)
        {
            if (pf.Name.Equals("mSelectionDivider"))
            {
                pf.Accessible = true;
                pf.Set(picker, new ColorDrawable(Android.Graphics.Color.Red));
            }
        }
    }
And invoked it after calling SetDisplayedValues
if (model.Items != null && model.Items.Any())
{
   // set style here
   picker.MaxValue = model.Items.Count - 1;
   picker.MinValue = 0;
   picker.SetDisplayedValues(model.Items.ToArray());
   picker.WrapSelectorWheel = false;
   picker.Value = model.SelectedIndex;
}
setNumberPickerDividerColor(picker);
        Lucas Zhang
        
- 18,630
 - 3
 - 12
 - 22
 
