gpt4 book ai didi

React-native textAlign 对齐

转载 作者:行者123 更新时间:2023-12-03 22:16:25 26 4
gpt4 key购买 nike

安卓

我试图使用 textAlign 使文本对齐,但它不起作用。

<Text style={{textAlign: 'justify',color:'#1B3D6C', margin: 20}}>
Lorem ipsum dolor sit amet, et usu congue vocibus, ei sea alienum repudiandae, intellegam quaerendum an nam. Vocibus apeirian no vis, eos cu conguemoo scaevola accusamus. Et sea placerat persecutii oinn
</Text>

enter image description here

编辑 :
好的, textAlign justify 在 Android 上不起作用,所以我现在问是否有一些解决方案?我真的需要!

最佳答案

Android 不支持文本对齐。 React Native Text component 的文档关于样式属性说:

textAlign enum('auto', 'left', 'right', 'center', 'justify') : Specifies text alignment. The value 'justify' is only supported on iOS and fallbacks to left on Android.



此限制的解决方法是使用 React Native WebView成分。 WebView 的内容可以是带有对齐文本的 HTML 代码。像这样:
<View style={{flex: 1}}>
<WebView
source={{ html: "<p style='text-align: justify;'>Justified text here</p>" }}
/>
</View>

关于React-native textAlign 对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43873546/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com