react-native-keyboard-aware-scroll-view 在 Android 上没有滚动,这是一个问题,因为当我点击顶部的 textInput 时,它会消失,我无法将它滚动到视图中。
android:windowSoftInputMode="adjustPan"
到android清单,我在文件顶部导入了react-native-keyboard-aware-scroll-view。这是我拥有的代码。
<View>
<TouchableOpacity style={this.props.addressDisplayStyle} accessibilityLabel={'addressSelected'} onPress={() => this.setState({showModal: true})}>
<Text numberOfLines={6} ellipsizeMode ={'tail'} style={[styles.text, styles.secondaryText, styles.selectedText, styles.addressText]}>{this.props.address}</Text>
</TouchableOpacity>
<Modal
animationType="fade"
transparent={true}
visible={this.state.showModal}
onRequestClose={() => this.closeModal()}
>
<KeyboardAwareScrollView
resetScrollToCoords={{ x: 0, y: 0 }}
contentContainerStyle={[styles.fadedBackground, { justifyContent: 'center', flexGrow: 1}]}
scrollEnabled={true}
enableAutomaticScroll={(Platform.OS === 'ios')}
enableOnAndroid={true}
>
<View style={styles.modalContainer}>
<Text style={[styles.text, styles.titleText]}>Enter Address</Text>
<TextInput
maxLength={300}
multiline = {false}
placeholder = {'123 Street'}
style = {[styles.text, styles.inputText, styles.inputTextCustom]}
onChangeText={(changedText) => this.setState({street: changedText})}
value={this.state.street}
/>
<TextInput
maxLength={300}
multiline = {false}
placeholder = {'Apt #'}
style = {[styles.text, styles.inputText, styles.inputTextCustom]}
onChangeText={(changedText) => this.setState({street2: changedText})}
value={this.state.street2}
/>
<TextInput
maxLength={300}
multiline = {false}
placeholder = {'city'}
style = {[styles.text, styles.inputText, styles.inputTextCustom]}
onChangeText={(changedText) => this.setState({city: changedText})}
value={this.state.city}
/>
<TextInput
maxLength={2}
multiline = {false}
placeholder = {'State'}
style = {[styles.text, styles.inputText, styles.inputTextCustom]}
onChangeText={(changedText) => this.setState({state: changedText})}
value={this.state.state}
/>
<TextInput
maxLength={10}
keyboardType={'numeric'}
multiline = {false}
placeholder = {'Zipcode'}
style = {[styles.text, styles.inputText, styles.inputTextCustom]}
onChangeText={(changedText) => this.setState({zipcode: changedText})}
value={this.state.zipcode}
/>
{this.state.loading?
<Loading />
:
null
}
</View>
</KeyboardAwareScrollView>
</Modal>
</View>
我曾尝试在 KeyboardAwareScrollView 之前和之后添加滚动视图,并有一个视图来扭曲它,但我似乎无法让它适用于 android。