【问题标题】:Drag and drop from ScrollView React Native从 ScrollView React Native 拖放
【发布时间】:2021-02-02 18:47:51
【问题描述】:

我想将屏幕一分为二以作为拖放列表。当我使用视图时,它工作正常。 但我必须使用 ScrollView,因为第二列有多重内容。

如何将 Dropitem 从 ScrollView 叠加到 View?

小吃https://snack.expo.io/@sitenative/two-columns-drag

【问题讨论】:

  • 我没有看过你的代码,但我从截图中的第一个预感是这是一个样式问题。确保你没有 overflow=hidden 并且顶部元素在代码的后面,或者使用 zIndex reactnative.dev/docs/layout-props#zindex

标签: react-native


【解决方案1】:

即使这可能无法回答您的问题,我也为您的问题找到了一种可能对您有用的解决方案/解决方法。 我将样式从scrollView style prop 移到contentContainerStyle,并且基本上将整个scrollView 剩余的空间用作将要放置项目的视图。

  <SafeAreaView style={styles.container}>
                <ScrollView
                    style={{backgroundColor: 'brown'}}
                    scrollEnabled={this.state.scroll}
                    contentContainerStyle={styles.drag}
                    showsVerticalScrollIndicator={false}
                    disableScrollViewPanResponder={true}
                    nestedScrollEnabled={true}
                >
                    {sheet.map((object, i) =>
                        <DragItem
                            key={'top_'+i}
                            color={object.color}
                            first={!i}
                            name={object.name}
                            scrollUpdate={this.scrollUpdate}
                        />
                    )}
                </ScrollView>
            </SafeAreaView>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-04
    相关资源
    最近更新 更多