如何防止我的卷轴回到顶部? (反应天然)
为了创建可滚动UI,我决定使用scrollview显示所有组件。但是,每当我尝试滚动到底部时,该应用在释放手指后立即弹回顶部。我尝试在ScrollView及其父视图中添加样式,但这似乎并没有帮助我的情况。
这是我的代码:
export default function App() {
const items = [
<TopText key='1' />,
<Bar key='2' />,
<TabDivider key='3' type="Carpool" />,
<Tiles key='4' />,
<TabDivider key='5' type="Schedule" />,
<Schedule key='6' />]
return (
<View style={styles.container}>
<ScrollView style={styles.scrollViewStyle}>
{items}
</ScrollView>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
position: 'relative',
flex: 1,
backgroundColor: 'rgba(187, 248, 237, 0.41)',
},
scrollViewStyle: {
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
}
});
如果您可以帮助我,我将非常感谢:D
In order to create a scrollable UI, I decided to use a ScrollView to display all my components. However, whenever I try to scroll to the bottom, the app bounces back to the top as soon as I release my finger. I've tried adding styling to the ScrollView and its parent view, but it doesn't seem to help my situation.
Here is my code:
export default function App() {
const items = [
<TopText key='1' />,
<Bar key='2' />,
<TabDivider key='3' type="Carpool" />,
<Tiles key='4' />,
<TabDivider key='5' type="Schedule" />,
<Schedule key='6' />]
return (
<View style={styles.container}>
<ScrollView style={styles.scrollViewStyle}>
{items}
</ScrollView>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
position: 'relative',
flex: 1,
backgroundColor: 'rgba(187, 248, 237, 0.41)',
},
scrollViewStyle: {
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
}
});
If you can help me, I would appreciate it a lot :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我弄清楚了!我要做的就是将卷轴围绕视图包裹,并编辑样式。这是更新的代码:
I figured it out! What I had to do was wrap the ScrollView around the view, and edit the styling. Here is the updated code: