反应原生滚动视图不会从文本输入内部滚动 [英] react native Scroll View doesn't scroll from inside text input
本文介绍了反应原生滚动视图不会从文本输入内部滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在滚动视图中添加了多文本输入.问题是当我想从文本输入内部向下滚动时,我将手指放在文本输入内部并向下滚动但它没有向下滚动页面,有没有办法解决这个问题?这是一个示例代码:
I added multi Text input inside a scroll view. the problem is when I want to scroll down from inside of a text input, I put my finger inside a text input and scroll down but it doesn't scroll down the page, is there a way to fix this? here is a sample code:
export default class ScrollViewWithTextInput extends React.Component {
render() {
<ScrollView>
<TextInput
style={styles.input}
placeholder={'توضیحات'}
underlineColorAndroid='transparent'
/>
<TextInput
style={styles.input}
placeholder={'توضیحات'}
underlineColorAndroid='transparent'
/><TextInput
style={styles.input}
placeholder={'توضیحات'}
underlineColorAndroid='transparent'
/><TextInput
style={styles.input}
placeholder={'توضیحات'}
underlineColorAndroid='transparent'
/>
<TextInput
style={styles.input}
placeholder={'توضیحات'}
underlineColorAndroid='transparent'
/>
<TextInput
style={styles.input}
placeholder={'توضیحات'}
underlineColorAndroid='transparent'
/><TextInput
style={styles.input}
placeholder={'توضیحات'}
underlineColorAndroid='transparent'
/><TextInput
style={styles.input}
placeholder={'توضیحات'}
underlineColorAndroid='transparent'
/>
</ScrollView>
}}
const styles = StyleSheet.create({
Container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
marginTop: 8
},
input: {
width: 350,
height: 100,
margin: 5,
borderColor: 'black',
borderWidth: 2,
textAlign: 'right'
}})
推荐答案
出于某种原因,将 multiline={true}
设置为 TextInput 对我有用.
For some reason setting multiline={true}
to the TextInput worked for me.
不确定为什么.更奇怪的是,如果您还有 keyboardType='numeric'
,它就不会工作.
Not exactly sure why. Stranger still, it will not work if you also have keyboardType='numeric'
.
这篇关于反应原生滚动视图不会从文本输入内部滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文