Xamarin形式的Picker控件中的字体大小 [英] Font size in Picker control in xamarin forms
问题描述
我很惊讶地发现Picker控件没有用于设置字体大小的字体大小属性.我需要为选择器控件设置字体大小.请提出如何设置字体大小?
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?
推荐答案
底层滚动条Xamarin.Form
选择器列表由本机控件(例如iOS UIPickerView
,Android的DatePicker
| TimePicker
,...)处理,并且对这些控件的访问内部 PickerRender
类.
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.
示例:
在iOS上,您需要创建一个自定义UIPickerView
类并覆盖ViewFor
方法,并为分配了自定义字体属性的每一行返回一个UILabel
.
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.
在Android上,您将创建标准选择器(例如DatePicker
),并执行FindViewById
来访问组成该选择器的各种EditText
,并为您的自定义项分配TextSize
属性字体大小.
On Android, you would create the standard picker, say a DatePicker
, and do a FindViewById
to access the various EditText
s that make up that picker and assign the TextSize
property to each with your custom font size.
这篇关于Xamarin形式的Picker控件中的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!