首页 > 解决方案 > 如何处理 inputBox 以 scrollheight 的 keyboardAwareScrollView 为焦点

问题描述

我有一个带有下拉菜单的输入框。这里我使用了 KeyboardAwareScrollView。我为整个屏幕设置了 extraScrollHeight。

如果我专注于屏幕上的特定 inputBox,如何设置 extraScrollHeight 为 100。

请参阅我尝试过的代码

state = { isFocused: false }

   handleInputFocus = () => this.setState({ isFocused: true })

  <KeyboardAwareScrollView bounces = {false}
            style = {{marginBottom:"7%"}}
            scrollEnabled={true}
            onFocus={this.handleInputFocus}
            keyboardShouldPersistTaps={'always'} stickyHeaderIndices = {[0]}
            extraScrollHeight = { isFocused ? 0 : 100 }
            >

  <TextInput underlineColorAndroid={'transparent'} style={{borderWidth: 1,
          borderColor: '#d6d7da',
          backgroundColor: '#ffffff'}} value={name} />

标签: react-nativekeyboardtextinput

解决方案


推荐阅读