简体   繁体   English

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

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

Drop down scroll is not working inside another scroll in react-native-dropdown-picker下拉滚动在 react-native-dropdown-picker 的另一个滚动中不起作用

I already tried giving我已经尝试过给予

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

 }}

to the as a prop.作为道具。 But still not working.但仍然无法正常工作。

here is my code这是我的代码

<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>

The scroll bar shows in the dropdown but its not scrollable.滚动条显示在下拉列表中,但不可滚动。 here is a reference image..这是一个参考图像..

这是一张图片

As per their official documentation, you can't have a inside scrollview.根据他们的官方文档,您不能拥有内部滚动视图。

Notes#笔记#

The FlatList component shouldn't be nested inside ScrollView or you'll come across the VirtualizedLists should never be nested inside plain ScrollViews warning. FlatList组件不应嵌套在ScrollView中,否则您将遇到 VirtualizedLists 永远不应嵌套在普通 ScrollViews 警告中。 If this happens to you and you only have a few items, consider using the SCROLLVIEW mode.如果您遇到这种情况并且您只有几个项目,请考虑使用SCROLLVIEW模式。 Otherwise you have to use the MODAL mode.否则你必须使用MODAL模式。

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

If you are facing issue with nested scrolling.如果您遇到嵌套滚动的问题。 Use ScrollView of react-native-gesture-handler with nestedScrollEnabled={true}.使用带有 nestedScrollEnabled={true} 的 react-native-gesture-handler 的 ScrollView。 It works better in android.它在 android 中效果更好。 You can also patch react-native-dropdown-picker for that.您还可以为此修补 react-native-dropdown-picker。

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

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