React native 如何在底部查看背景?
我想削减一点背景色,让文字的一半与它 我尝试使用React native 如何在底部查看背景?,react-native,flexbox,React Native,Flexbox,我想削减一点背景色,让文字的一半与它 我尝试使用marginBottom,但文本位置将随之移动 return ( <View style={{ flex: 1, backgroundColor: 'pink' }> <View style={{ felx: 1, backgroundColor: 'blue', marginBottom: 40, justifyContent: 'flex-end' }}> <Text style={{ f
marginBottom
,但文本位置将随之移动
return (
<View style={{ flex: 1, backgroundColor: 'pink' }>
<View style={{ felx: 1, backgroundColor: 'blue', marginBottom: 40, justifyContent: 'flex-end' }}>
<Text style={{ fontSize: 86, color: 'white' }}>Half</Text>
</View>
</View>
);
返回(
一半
);
有什么简单的方法可以实现吗
谢谢。我的想法有点不同。尝试插入另一个视图,并将
位置:'absolute'
指定给该视图,如下所示
<View style={{ flex: 1, backgroundColor: 'pink' }}>
<View style={{ flex: 1, backgroundColor: 'blue', marginBottom: 40, justifyContent: 'flex-end' }}>
<View style={{ bottom: -43, position: 'absolute' }}>
<Text style={{ fontSize: 86, color: 'white' }}>Half</Text>
</View>
</View>
</View>
一半
当您为底部指定值时
请确保指定一半的字体大小
希望这对你有帮助。请不要怀疑。可能会对您有所帮助。是的,您可以通过为文本提供绝对样式来实现。我曾尝试使用绝对样式,但它将丢失父视图。@KishanBharda谢谢,但它看起来有点不同,它是文本后面带有颜色的文本。请进一步解释我们没有理解您的意思。毫无疑问。这是正确的解决方案。谢谢你的帮助。