【发布时间】:2019-08-29 12:53:32
【问题描述】:
【问题讨论】:
-
但这对我不起作用
标签: react-native react-native-text
【问题讨论】:
标签: react-native react-native-text
【讨论】:
alignItems 或justifyContent 并避免flex: 1
alignSelf: 'flex-start' 添加到您的<View /> 样式即可解决您的问题。看到这个截图imgur.com/W1neB4g@sejn
添加视图并为视图留出边距并为视图添加边框。
<View style={{borderWidth:1,bordercolor:"Black",marginBottom:2}}>
<Text style={{fontSize:12}>28.Aug 2019</Text>
</View>
【讨论】:
这里有一个简单的解决方法来解决文本边框贯穿整个屏幕宽度的问题。用flexDirection:"row" 将其包裹在View 中。
<View style={{
flexDirection:"row"
}}>
<Text
style={{
borderBottomWidth:1,
paddingBottom:3
}}
>
My Text
</Text>
</View>
https://snack.expo.io/@ammarahmed/grounded-watermelon
要使其在 android 和 ios 上运行,请使用以下方法。您需要使用TextInput 才能使其工作。不管你想写什么,写在value中,并将editable设置为false
<View style={{
flexDirection:"row"
}}>
<TextInput
style={{
borderBottomWidth:1,
paddingBottom:3,
borderBottomColor:"black",
}}
editable={false}
value="My Text"
/>
</View>
【讨论】:
你也可以使用textDecorationLine
<Text style={{ fontSize: 18, textDecorationLine: 'underline' }}>28.Aug 2019</Text>
【讨论】: