TouchablewithoutFeedback 内部的 ScrollView
ScrollView inside of TouchablewithoutFeedback
我正在尝试制作文本reader。它有Header 和一个包含大量字符的内容,所以需要scrollview 让用户阅读所有的员工。
但现在让我困惑的是,我试图隐藏 header 当人们短时间按下屏幕时,当人们向下滚动时,手指触摸屏幕并移动一点, header 还在。
现在我尝试的是,
<TouchableWithoutFeedback style={{padding: 40}} onPress={()=>this.pressScreen()} pressRetentionOffset={{top:1,left:1,bottom:1,right:1}}>
<ScrollView style={{width: screen.width,
height:screen.height*0.8}}>
<Text>{this.state.data.chptTitle}</Text>
<Text>{this.state.data.chptContent}</Text>
</ScrollView>
</TouchableWithoutFeedback>
但显然它不起作用,因为 pressRetentionOffset 无法与 scrollView 一起使用。
我应该怎么办?有什么建议吗?
我不会将其包装在 onPress 上。我会将 ScrollView 设为 parent,然后将所有文本包装在 parent 文本中,然后使用 parent <Text>
的 onPress
。像这样:
<ScrollView style={{padding: 40, width: screen.width,
height:screen.height*0.8}}>
<Text onPress={()=>this.pressScreen()}>
<Text>{this.state.data.chptTitle}</Text>
<Text>{this.state.data.chptContent}</Text>
</Text>
</ScrollView>
就我个人而言,让 ScrollView
成为 Touchable*
的 child 没有任何意义
我正在尝试制作文本reader。它有Header 和一个包含大量字符的内容,所以需要scrollview 让用户阅读所有的员工。
但现在让我困惑的是,我试图隐藏 header 当人们短时间按下屏幕时,当人们向下滚动时,手指触摸屏幕并移动一点, header 还在。
现在我尝试的是,
<TouchableWithoutFeedback style={{padding: 40}} onPress={()=>this.pressScreen()} pressRetentionOffset={{top:1,left:1,bottom:1,right:1}}>
<ScrollView style={{width: screen.width,
height:screen.height*0.8}}>
<Text>{this.state.data.chptTitle}</Text>
<Text>{this.state.data.chptContent}</Text>
</ScrollView>
</TouchableWithoutFeedback>
但显然它不起作用,因为 pressRetentionOffset 无法与 scrollView 一起使用。 我应该怎么办?有什么建议吗?
我不会将其包装在 onPress 上。我会将 ScrollView 设为 parent,然后将所有文本包装在 parent 文本中,然后使用 parent <Text>
的 onPress
。像这样:
<ScrollView style={{padding: 40, width: screen.width,
height:screen.height*0.8}}>
<Text onPress={()=>this.pressScreen()}>
<Text>{this.state.data.chptTitle}</Text>
<Text>{this.state.data.chptContent}</Text>
</Text>
</ScrollView>
就我个人而言,让 ScrollView
成为 Touchable*