Reputation: 666
Why is Picker's layout being so altered when I apply a custom renderer?
layout after applying Renderer:
How to leave the original layout but applying a custom renderer?
And also the confirm button are not showing up anymore. They are white, if you click where they should be they work.
Custom Renderer:
public class MyPickerRenderer : PickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
if (Control != null)
{
var spinner = new Spinner(this.Context);
Control.SetBackgroundColor(Color.Transparent.ToAndroid());
Control.InputType = InputTypes.TextFlagNoSuggestions;
Control.SetTextColor(Color.Red.ToAndroid());
spinner.SetBackgroundColor(Color.Red.ToAndroid());
}
}
}
Upvotes: 2
Views: 864
Reputation: 4302
I had the same problem, and found the solution is this: Make sure you are using Xamarin.Forms.Platform.Android.AppCompat.PickerRenderer not Xamarin.Forms.Platform.Android.PickerRenderer
Answer from here: https://forums.xamarin.com/discussion/100317/custom-renderer-for-picker-automatically-changes-layout-in-app-without-overrides
Upvotes: 2