使用react-native-dialog,如何更改对话框的高度和宽度

时间:2019-08-27 09:47:28

标签: react-native

我正在研究React Native应用程序。我正在使用“ react-native-dialog ”。我想更改对话框的高度和宽度。我做不到。我的代码是:

import Dialog from "react-native-dialog";

<Dialog.Container style={{height: "50%", width: "50%"}} visible={this.state.dialogVisible}>

    <Dialog.Title>Edit Your Note</Dialog.Title>

    <Dialog.Input multiline={true} onChangeText={(nm)=> this.setState({newNote: nm})}
    value={this.state.newNote}></Dialog.Input>

    <Dialog.Button label="Cancel" onPress={() => this.handleCancel(e.ans)} />
    <Dialog.Button label="Save" onPress={() => this.handleSave(e.idx, e.ans)} />
  </Dialog.Container>

我想增加对话框的高度和宽度,以便可以增加“ Dialog.Input”的高度和宽度。目前,我的对话框如下:

enter image description here

2 个答案:

答案 0 :(得分:1)

您需要在容器中添加视图。希望对您有帮助。

     <Dialog.Container visible={this.state.dialogVisible} style={{ 
       justifyContent:'center', alignItems: 'center', backgroundColor: 'pink' }}>
         <View style={{ height: '70%', width: '70%' }}>
           <Dialog.Title>Edit Your Note</Dialog.Title>

           <Dialog.Input multiline={true} onChangeText={(nm) => 
          this.setState({ newNote: nm })}
             value={this.state.newNote}></Dialog.Input>
         </View>
         <Dialog.Button label="Cancel" onPress={() => this.handleCancel(e.ans)} />
         <Dialog.Button label="Save" onPress={() => this.handleSave(e.idx, e.ans)} />

       </Dialog.Container>

答案 1 :(得分:1)

“ contentStyle” 帮助我解决了该问题。我的代码是:

alpha = 0.3

现在,视图为:

enter image description here