scrollview can't scroll when focus textinput react native

后端 未结 5 815
执笔经年
执笔经年 2021-01-20 04:38

I have a TextInput inside a ScrollView.

The scroll isn\'t working when the TextInput is on focus. This problem is only affecting Android.

5条回答
  •  感情败类
    2021-01-20 05:11

    I handle in different ways to each platform (in Ios focus to inputText is enough, don't forget to put this.scrollViewRef ref inside ScrollView that wrap inputText and put ref index the inputText

    if (Platform.OS == 'android') {
        this.inputRefs[field].measure((w, h, px, py, xPage, yPage) => {
            this.scrollViewRef.scrollTo({ x: 0, y: yPage, animated: true })
            this.inputRefs[field].focus()
        })
    } 
    this.inputRefs[field].focus()
    

提交回复
热议问题