将宽度和高度设置为React-native模态 [英] Set width and height to React-native modal

查看:167
本文介绍了将宽度和高度设置为React-native模态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用 style 属性配置模态高度和宽度.还有其他方法可以设置模式的高度和宽度吗?

I can't configure modal height and width using style property. Is there any other way to set modal height and width?

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

上面的代码不起作用.

推荐答案

根据模式文档,没有要设置的style属性.

According to the Modal documentation, there is no style prop to be set.

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

You can try setting the <View> dimensions inside the <Modal> instead:

<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>

这篇关于将宽度和高度设置为React-native模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆