保持textInput时,本机Scroll不起作用

时间:2017-02-13 16:54:08

标签: react-native react-native-android

我有注册表单的android应用程序。它的代码:

<View style={{flex:1}}>
    <ScrollView style={{flex:1, backgroundColor='#ffffff'}}>
        <More components...>
        <TextInput style={styles.inputText} 
                   value={this.state.mail}
                   placeholder="Email"
                   onChangeText={(text)=>this.setState.(mail:text)}/>
        <TextInput style={styles.inputText} 
                   value={this.state.fName}
                   placeholder="First name"
                   onChangeText={(text)=>this.setState.(fName:text)}/>
        <TextInput style={styles.inputText} 
                   value={this.state.sName}
                   placeholder="Second name"
                   onChangeText={(text)=>this.setState.(sName:text)}/>
        <More components...>
    </ScrollView>
</View>

但是当用户按住TextInput并开始滚动时,视图不会滚动。在其他控件中,滚动效果很好。

1 个答案:

答案 0 :(得分:0)

<ScrollView style={{flex:1, backgroundColor='#ffffff'}}>
<View style={{flex:1}}>    
    <More components...>
    <TextInput style={styles.inputText} 
               value={this.state.mail}
               placeholder="Email"
               onChangeText={(text)=>this.setState.(mail:text)}/>
    <TextInput style={styles.inputText} 
               value={this.state.fName}
               placeholder="First name"
               onChangeText={(text)=>this.setState.(fName:text)}/>
    <TextInput style={styles.inputText} 
               value={this.state.sName}
               placeholder="Second name"
               onChangeText={(text)=>this.setState.(sName:text)}/>
    <More components...>

滚动元素必须包含一个视图