I try to change the items font size in Xamarin.Picker for my Android app. In my project, I use BindablePicker
that inherits from Picker class. Source here.
I spent some time to do research and I found that I should create a PickerRenderer
class and render the Picker.
My renderer class:
public class BindablePickerRenderer : PickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
var picker = e.NewElement;
BindablePicker bp = (BindablePicker)this.Element;
if (this.Control != null)
{
var pickerStyle = new Style(typeof(BindablePicker))
{
Setters =
{
new Setter { Property = VisualElement.BackgroundColorProperty, Value = Color.Red }
}
};
picker.Style = pickerStyle;
}
}
}
For test purposes I set the backgroundColor for Picker
and it works fine. However, in my PickerRenderer
class I only have access to Control
property which is type of Android.Widget.EditText
.
The effect :
Question
How can I access to Picker
items, and set the font size for them? Is this possible?
Here is my repository with an example project.
https://github.com/k8mil/PickerRendererXamarin
Related links
https://developer.xamarin.com/api/type/Xamarin.Forms.Picker/
Changing the default text color of a Picker control in Xamarin Forms for Windows Phone 8.1