我目前正在使用ScrollView来保存我的所有卡片,如
<ScrollView>
<Card id={1}/>
<Card id={2}/>
</ScrollView>
Card
是一个自定义组件,基本上只是具有一定宽度和高度的视图。
我使用PanResponder来定义拖动动画并将处理程序附加到每个卡上。
this._panResponder = PanResponder.create({
onPanResponderGrant: (e, gestureState) => {
this.state.pan.setOffset({x: this.state.pan.x._value, y: this.state.pan.y._value});
},
onPanResponderMove: Animated.event([
null, {dx: this.state.pan.x, dy: this.state.pan.y},
]),
onPanResponderRelease: (e, {vx, vy}) => {
this.state.pan.flattenOffset()
}
});
所以Card
组件只渲染动画视图,如
<Animated.View {...this._panResponder.panHandlers}>
...
</Animated.View>
我可以将卡片拖动到滚动视图内的任何位置,滚动视图的部分溢出将被隐藏。如何将卡片放在scrollView的顶部,然后我可以拖动并在屏幕上的任何位置显示它。
我将ScrollView
更改为View
后发现的有趣事情,Card
可以拖到View
之上。它仅适用于iOS,Android仍与ScrollView
相同。
答案 0 :(得分:2)
您尝试做的事情不会在Android上运行。这是因为RN不支持Android overflow:visible
中的zip -u f.zip f.py; aws lambda update-function-code --zip-file fileb://f.zip --function-name f
。
溢出样式属性默认为隐藏,无法在Android上更改
这意味着您必须使用容器视图的层次结构,并考虑一种解决方法,将卡片放在更大的容器中或复制到另一个层中。