在 Xamarin Forms 中更改我的应用程序的字体(所有标签/列表视图...)

1 fonts label listview button xamarin.forms

我想用我的应用程序的自定义字体更改我的字体系列。

在 Xamarin 文档中,我可以看到如何仅更改一个标签的字体系列,但不能更改我的整个应用程序!

我使用适用于 Android 和 IOS 的 Xamarin Forms!

我需要更改我的字体:-Listviews -Buttons -Label

谢谢

Jas*_*son 5

您可以使用全局样式将更改应用到应用程序中的所有元素。要更改所有 Label 元素的字体,您可以这样做:

<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Styles.App">
    <Application.Resources>
        <ResourceDictionary>
            <Style TargetType="Label">
                <Setter Property="FontFamily" Value="sans-serif" />
                <Setter Property="FontSize" Value="12" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>
Run Code Online (Sandbox Code Playgroud)

  • 我看到了这篇文章,但它仅适用于一个标签,不适用于我的所有应用程序 (2认同)