标签中的上标文本 [英] Superscript text in Label

查看:16
本文介绍了标签中的上标文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Xamarin Forms 中为标签添加上标?在 HTML 中,我会使用 标签.我想上标文本min".所以我可以在文本5min"上加上min"部分.

Is it possible to superscript a label in Xamarin Forms? In HTML I would use the <sup> tag. I want to superscript the text "min". So I can have the text "5min" with the "min" part superscripted.

推荐答案

感谢 Jason 使用 FormattedText 属性的想法.但是由于它不支持文本的绑定,我将2个标签放在一个StackLayout中,上标文本为微字号:

Thanks to Jason for his idea of using FormattedText property. But since it doesn't support binding of the text, I put 2 labels together in a StackLayout, the superscript text in mirco font size:

<StackLayout Orientation="Horizontal" Spacing="0">
                <Label Text="{Binding Minutes}">
                    <Label.FontFamily>
                        <OnPlatform x:TypeArguments="x:String">
                            <On Platform="Android" Value="fonts/chsans/MyFont-Bold.ttf#MyFont-Bold" />
                        </OnPlatform>
                    </Label.FontFamily>
                </Label>
                <Label Text="min" FontSize="Micro">
                    <Label.FontFamily>
                        <OnPlatform x:TypeArguments="x:String">
                            <On Platform="Android" Value="fonts/chsans/MyFont-Regular.ttf#MyFont-Regular" />
                        </OnPlatform>
                    </Label.FontFamily>
                </Label>
</StackLayout>

这篇关于标签中的上标文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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