Xamarin形式的Picker控件中的字体大小 [英] Font size in Picker control in xamarin forms

查看:218
本文介绍了Xamarin形式的Picker控件中的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很惊讶地发现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 EditTexts that make up that picker and assign the TextSize property to each with your custom font size.

这篇关于Xamarin形式的Picker控件中的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆