将宽度和高度设置为 React-native modal

新手上路,请多包涵

我无法使用 style 属性配置模态高度和宽度。有没有其他方法可以设置模态高度和宽度?

  <Modal style={{height: 300, width: 300}}
        visible={this.state.isVisible}
        onRequestClose={this.closeModal}>
 </Modal>

上面的代码不起作用。

原文由 TK-95 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.2k
1 个回答

根据 Modal 文档,没有要设置的 style 道具。

您可以尝试在 --- 内设置 <Modal> <View> 尺寸:

 <Modal transparent={true}
       visible={this.state.isVisible}
       onRequestClose={this.closeModal}>
  <View style={{
          flex: 1,
          flexDirection: 'column',
          justifyContent: 'center',
          alignItems: 'center'}}>
    <View style={{
            width: 300,
            height: 300}}>
      ...
    </View>
  </View>
</Modal>

原文由 max23_ 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏