我在 ScrollView 中添加了多文本输入。问题是当我想从文本输入内部向下滚动时,我将手指放在文本输入内部并向下滚动,但它没有向下滚动页面,有没有办法解决这个问题? 这是示例代码:
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 对我有用。
不太清楚为什么。更奇怪的是,如果您还有 keyboardType='numeric'
,它将无法工作。
关于reactjs - react native ScrollView 不会从文本输入内部滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46564649/