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

Android Picker - Text Color?

$
0
0

Is there a way to change the Text color of the Xamarin Forms Picker for Android? (The sponner that pops up, not the actual control that shows the choice made.)

I've tried this, but the Spinner is always null???

 public class CustomPickerRenderer : PickerRenderer 
   {
       protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
      {

        base.OnElementChanged(e);
        if (e.OldElement == null)
        {

            CustomPicker element = (CustomPicker)this.Element;
            var nativePickerView = (global::Android.Widget.TextView) Control;


            // do whatever you want to the textField here!
            element.BackgroundColor = Color.Transparent;
            nativePickerView.SetBackgroundColor(element.BackgroundColor.ToAndroid());
           // nativePickerView.SetBackgroundResource(Resource.Drawable.);
            nativePickerView.SetCursorVisible(true);
            nativePickerView.SetTextColor(Color.Black.ToAndroid());
          //  nativePickerView.SetHintTextColor(element.PlaceholderColor.ToAndroid());
          //  nativePickerView.Hint = element.Placeholder;
          //  nativePickerView.SetBackgroundResource(Resource.Drawable.txtbg);
            //nativePickerView.SetBackgroundDrawable(DropBoxManager.);


            int spinnerId = nativePickerView.Context.Resources.GetIdentifier("android:id/Spinner", null, null);
            var spinnerView = (nativePickerView.FindViewById(spinnerId) as Spinner);
            if (spinnerView != null) spinnerView.SetBackgroundColor(Color.Black.ToAndroid());
        }
    }

Viewing all articles
Browse latest Browse all 91519

Trending Articles



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