android - 我需要在 Xamarin Forms 按钮内设置格式化文本(两种不同大小)

标签 android ios xaml xamarin xamarin.forms

我有一个 Xamarin Forms 项目,我需要一个自定义按钮。该按钮看起来像这样:

enter image description here

我假设我需要创建一个自定义渲染器,但我不知道如何在按钮内拥有两种不同的字体大小?

我需要同时适用于 Android 和 iOS 的渲染器。任何帮助将不胜感激。谢谢!

最佳答案

如何跳过自定义渲染器并使用带有包含格式化文本的点击手势的 Frame Label:

<Frame VerticalOptions="Center" HorizontalOptions="Center" CornerRadius="10" BackgroundColor="Gray" BorderColor="Black">
    <Frame.GestureRecognizers>
        <TapGestureRecognizer Tapped="OnFrameTapped"/>
    </Frame.GestureRecognizers>
    <Label>
        <Label.FormattedText>
            <FormattedString>
                <Span Text="2" FontSize="30" />
                <Span Text="ABC" FontSize="15" />
            </FormattedString>
        </Label.FormattedText>
    </Label>
</Frame>

enter image description here

关于android - 我需要在 Xamarin Forms 按钮内设置格式化文本(两种不同大小),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56926894/

相关文章:

android - 编译android 4.0.3时找不到-ltinfo

ios - NS自动释放池。什么时候适合创建一个新的自动释放池?

android - 无需在后台打开我的应用程序即可接收位置信息

silverlight - 如何仅使用 XAML 显示不同的 Enum 图标?

java - Android:增加整数会导致分配

android - .notifyDataSetChanged()问题

Android 从服务器自动完成 EditText

ios - 在 swift 3 的定时通知中更新角标(Badge)?

c# - Visual Studio 2013 和 C# - 无法添加事件处理程序

c# - 对绑定(bind)的可观察集合进行排序