我有一个屏幕,我在其中输入输入字段并相应地获得搜索结果。该列表在 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. 这使得可以稍微滚动一下。但是,当键盘打开时,我可以滚动但不能滚动到最后。如果我添加高度:100%,我根本无法滚动。
