react-native - React Native 按钮未对齐中心
问题描述
我在我的原生基本表单中包含了一个按钮,但它没有居中对齐。
<Form>
...
<Item inlineLabel>
<View style={styles.alignCenter}>
<Button primary style={styles.btnUpd}><Text> Update </Text></Button>
</View>
</Item>
</Form>
我的风格:
const styles = StyleSheet.create({
alignCenter: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center'
},
btnUpd: {
height: 35,
marginTop: 4,
marginBottom: 4,
}
});
我以为我只需要使用 justifyContent 和 alignItems center 来集中对象。我错过了什么?
谢谢
解决方案
使用标签将其设置为屏幕的中心,对于屏幕的左侧和<Body>
右侧,您可以使用如下所示:<Left>
<Right>
<View>
<Body>
<Button>
<Text> Update </Text>
</Button>
</Body>
</View>
推荐阅读
- java - 如何在 Spring Boot 应用程序中启动和停止 google pubsub 订阅者?
- c - 为什么我们在 C 中使用 \r 和 \b?
- linux - top 命令直到一个进程用完
- nginx - nginx 入口:在 nginx-controller 日志中忽略 yaml 定义中的冲突主机,但创建非工作情况
- python - 有没有一种安全的方式来存储网站的密码?
- c++ - DirectX 索引缓冲区 -> 索引缓冲区的开始
- addressbook - 如何使用 UserService 获取当前用户的完整详细信息,包括他们的默认地址?
- amazon-web-services - 如何重置 AWS codebuild 中的环境变量?
- c++ - 复合模如何在 C++ 中工作?
- c# - 如何使用代码在 Microsoft Teams 上启用可访问性