在Xamarin中用带样式的下划线给文本加下划线

时间:2019-12-06 11:55:55

标签: xamarin xamarin.forms

我想在文本上加下划线: Text with a styled underline

2 个答案:

答案 0 :(得分:0)

Xamarin表单提供了TextDecorations属性。请尝试以下代码

 <StackLayout
        Padding="30"
        BackgroundColor="#fafafa"
        HorizontalOptions="FillAndExpand"
        VerticalOptions="FillAndExpand">
        <Label
            FontSize="Large"
            HorizontalOptions="FillAndExpand"
            Text="The Steps"
            TextDecorations="Underline" />
    </StackLayout>

答案 1 :(得分:0)

您可以在框视图上方重叠标签以获得所需的结果。

    <Grid>
            <BoxView
                HeightRequest="6"
                HorizontalOptions="Start"
                WidthRequest="{Binding Source={x:Reference label}, Path=Width}" Color="Gold" VerticalOptions="End"/>
            <Label
                x:Name="label"
                FontSize="30"
                HorizontalOptions="Start"
                Text="The Steps">
            </Label>
        </Grid>

结果视图屏幕截图

result UI

但是,如果无法达到下划线处p下冲程周围的空间。如果需要空格,请尝试使用SkiaSharp(图形库)。

相关问题