【问题标题】:Center text with label in stacklayout with nativescript使用 nativescript 在 stacklayout 中使用标签居中文本
【发布时间】:2020-07-26 05:25:19
【问题描述】:

我想知道如何在堆栈布局中将带有标签 textwrap 的文本居中。

我尝试使用horizo​​ntalAlignment="center",小文本没问题(例如:“hello”、“test test”),但如果我在标签上使用textWrap,它就不起作用了……

<StackLayout v-for="(text, indexVerse) in texts"
                borderRadius="5" margin="5" padding="15" row="1" col="0" horizontalAlignment="center">

    <Label textWrap="true"
            :text="text.content"
            color="#FFFFFF"
            textAlign="center"
            fontSize="20"/>
</StackLayout>

文字设置在左侧,没有居中:

【问题讨论】:

    标签: nativescript nativescript-vue


    【解决方案1】:

    设置文本对齐的属性是textAlignment,如果它在模板上内联,text-align,如果你通过css设置它。

    尝试将textAlign 替换为textAlignment,如下所示:

    <Label textWrap="true"
                :text="text.content"
                color="#FFFFFF"
                textAlignment="center"
                fontSize="20"/>
    

    【讨论】:

    • 完美!谢谢@William!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-21
    • 2019-01-31
    • 1970-01-01
    • 1970-01-01
    • 2013-07-15
    • 1970-01-01
    相关资源
    最近更新 更多