android - React Native:嵌套文本的边框半径和填充样式
问题描述
我想对嵌套文本应用不同的边框半径和填充样式,但据我所知,react native 还不支持。有解决方法吗?
到目前为止我尝试的是:
<Text>
<Text
style={{
backgroundColor: 'green',
borderRadius: 12,
}}>
Text1
</Text>
<Text
style={{
backgroundColor: 'blue',
borderRadius: 12,
}}>
Text2
</Text>
</Text>
预期结果:具有不同背景和边框半径的文本。
实际结果:背景不同,但没有应用边界半径
解决方案
您可以将此代码放在文本样式中
<View
style={{
backgroundColor: 'green',
borderRadius: 10,
borderWidth: 1,
borderColor: '#fff',
padding: 10
}}>
<Text>Text1</Text>
</View>