繁体   English   中英

另一个滚动中的 react-native-dropdown-picker 滚动不起作用

[英]react-native-dropdown-picker scroll inside another scroll is not working

下拉滚动在 react-native-dropdown-picker 的另一个滚动中不起作用

我已经尝试过给予

listMode="SCROLLVIEW"
    scrollViewProps={{
      nestedScrollEnabled: true,

 }}

作为道具。 但仍然无法正常工作。

这是我的代码

<SafeAreaView edges={['right', 'left', 'bottom']} style={styles.container} >
                <ScrollView>
                    <View style={[globalStyles.contentWrap, { marginBottom: 16, height: 1000 }]}>
                        <View>

                            <View style={{ zIndex: 10 }}>

                                <DropDownPicker
                                    listMode="SCROLLVIEW"
                                    placeholder="Select your restaurant"
                                    style={{
                                        borderColor: Colors.borderColor,
                                        backgroundColor: '#fff',
                                        borderWidth: 1,
                                        paddingHorizontal: 12,
                                        paddingVertical: Platform.OS === 'ios' ? 12 : 6,
                                        fontSize: 16,
                                        borderRadius: 5,
                                        marginTop: 8,
                                        marginBottom: 16,
                                    }}
                                    dropDownContainerStyle={{
                                        borderColor: Colors.borderColor,
                                        color: Colors.black1,
                                        fontSize: 16,
                                        borderRadius: 5,
                                    }}
                                    placeholderStyle={{
                                        color: '#696969',
                                        fontSize: 16,
                                    }}
                                    textStyle={{
                                        fontSize: 16,
                                    }}
                                    dropDownMaxHeight={240}
                                    open={open}
                                    value={value}
                                    items={items}
                                    setOpen={setOpen}
                                    setValue={setValue}
                                    setItems={setItems}
                                    schema={{
                                        label: 'name',
                                        value: 'id',
                                    }}
                                />
                            </View>
                        </View>

                    </View>
                </ScrollView>
            </SafeAreaView>

滚动条显示在下拉列表中,但不可滚动。 这是一个参考图像..

这是一张图片

根据他们的官方文档,您不能拥有内部滚动视图。

笔记#

FlatList组件不应嵌套在ScrollView中,否则您将遇到 VirtualizedLists 永远不应嵌套在普通 ScrollViews 警告中。 如果您遇到这种情况并且您只有几个项目,请考虑使用SCROLLVIEW模式。 否则你必须使用MODAL模式。

请参阅此链接: https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/advanced/list-modes

如果您遇到嵌套滚动的问题。 使用带有 nestedScrollEnabled={true} 的 react-native-gesture-handler 的 ScrollView。 它在 android 中效果更好。 您还可以为此修补 react-native-dropdown-picker。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM