Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font size in Picker control in xamarin forms

I am surprised to see that Picker control does not have font size property to set font size. I had a need to set font size for picker control. Kindly suggest how do I set font size?

like image 626
Ravi Kanasagra Avatar asked Oct 18 '22 05:10

Ravi Kanasagra


1 Answers

The underlaying scrollable Xamarin.Form Picker list is handled by native controls such as iOS UIPickerView, Android's DatePicker|TimePicker, ... and access to these controls are internal to the PickerRender class.

You can create custom renderers for each of your targeted platforms and create custom views for each of them.

Example:

On iOS you would need to create a custom UIPickerView class and override the ViewFor method and return a UILabel for each row that has your custom font attributes assigned.

On Android, you would create the standard picker, say a DatePicker, and do a FindViewById to access the various EditTexts that make up that picker and assign the TextSize property to each with your custom font size.

like image 156
SushiHangover Avatar answered Dec 27 '22 11:12

SushiHangover