Jav*_*ana 1 alignment flexbox react-native
我在一个视图中有一个 TextInput,它有 alignItems='center'。通过此设置,TextInput 将采用 TextInput 中文本类型的长度。
<View style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center'
}} >
<TextInput />
<Text>This is React Native</Text>
</View>
Run Code Online (Sandbox Code Playgroud)
截图如下
而我想要实现的是将子项对齐在中心并拉伸 TextInput 的宽度以匹配父项
像这张图片
我如何在 react native 中实现这一点?
小智 5
<View
style={{
flex: 1,
justifyContent: "center",
}}>
<TextInput />
<Text
style={{
alignSelf: "center",
}}>
This is React Native
</Text>
</View>
Run Code Online (Sandbox Code Playgroud)
用你的代码替换上面的代码。
归档时间: |
|
查看次数: |
9379 次 |
最近记录: |