【发布时间】:2020-12-05 18:53:08
【问题描述】:
我有一个屏幕,我在其中输入输入字段并获得相应的搜索结果。该列表在 ScrollView 中呈现,但当键盘打开时(在 Android 中)它仍然不允许我滚动。
我该如何解决这个问题?
return (
<>
{addressesFound.length > 0 ? (
<ScrollView
style={styles.searchResultsContainer}
keyboardShouldPersistTaps={'always'}
keyboardDismissMode={'on-drag'}>
{addressesFound.map((addressDetails: addressDetailsType) => {
return (
<View
key={addressDetails.placeName}
style={styles.resultContainer}>
<Text
style={styles.text}>
{addressDetails.placeName}
</Text>
</View>
);
})}
</ScrollView>
) : null}
</>
);
};
const styles = StyleSheet.create({
searchResultsContainer: {
width: moderateScale(400),
paddingHorizontal: moderateScale(50),
paddingRight: moderateScale(65),
marginTop: moderateScale(10),
flex:1,
},
resultContainer: {
marginTop: moderateScale(10),
borderBottomWidth: 1,
borderBottomColor: 'grey',
},
text: {
fontSize: moderateScale(15),
},
});
我已经尝试添加 nestedScrollEnabled={true},但没有任何区别。
这是调用上述组件的地方:
<View style={styles.dropdown}>
<LocationsFound
addressesFound={locations.addressesFoundList} />
....
dropdown: {
position: 'absolute',
top: moderateScale(215),
zIndex: moderateScale(10),
backgroundColor: '#fff',
flex: 1,
},
我尝试将 height: 80% 添加到 dropdown。这使得可以滚动一点。但是,当键盘打开时,我可以滚动但不能滚动到最后。如果我添加 height: 100%,我根本无法滚动。
【问题讨论】:
标签: javascript css reactjs react-native uiscrollview