如何在标签中居中放置多行文字

时间:2020-02-11 19:12:17

标签: xamarin.forms

有人知道如何使用LineBreakMode=WordWrap将Xamarin表单标签中的文本居中(或对齐或以任何方式横向影响)吗?不使用WebView(或类似产品)?

在此代码段中,所有HorizontalOptions条目都会被忽略:

<StackLayout>
    <Label
        Margin="75,0,75,0"
        FontAttributes="Italic"
        FontSize="Large"
        HorizontalOptions="Center"
        LineBreakMode="WordWrap"
        Text="Live life as though nobody is watching, and express yourself as though everyone Is listening."
        VerticalOptions="CenterAndExpand" />
</StackLayout>

看起来像this

2 个答案:

答案 0 :(得分:2)

在这种情况下,您应该使用Horizo​​ntalTextAlignment =“ Center”。

job1:
    stage: build
    script: 
    - echo "JOb1"
    - curl -X POST -F token=2342344444 -F "variables[TRIGGER_JOB]=job1" -F ref=master https://main.gitlab.myconmpanyxyz.com/api/v4/projects/1234/trigger/pipeline
    only:
     changes:
       - job1.md
    except:
      variables:
        - $CI_PIPELINE_SOURCE == "trigger"

答案 1 :(得分:0)

将此行添加到您的代码中

Horizo​​ntalTextAlignment =“ Center”

<StackLayout>
    <Label
        Margin="75,0,75,0"
        FontAttributes="Italic"
        FontSize="Large"
        HorizontalOptions="Center"
        HorizontalTextAlignment="Center"
        LineBreakMode="WordWrap"
        Text="Live life as though nobody is watching, and express yourself as though everyone Is listening."
        VerticalOptions="CenterAndExpand" />
</StackLayout>