3

In my react-native app I've got a View that renders a TextInput and a ListView. The ListView is populated based on what is typed in the TextInput.

<View styleComponent={styleComponent.mainContainer}>
  <TextInput
    onChangeText={this.onTyping.bind(this)}
    value={this.state.text} />
  <ListView
    dataSource={this.state.dataSource}
    renderRow={(rowData) => this._renderRow(rowData)} />
</View>

My problem is that part of the ListView is rendered behind the IOS keyboard. Is there any way, without external libraries, to tell the ListView to render in the available space, i.e. not under the keyboard.

Axel Mani
  • 159
  • 2
  • 12

2 Answers2

3

You should use onBlur and onFocus event or keyboard events plugin and adjust your list style when keyboard opened. Take a look with this: how-to-auto-slide-the-window-out-from-behind-keyboard-when-textinput-has-focus.

Community
  • 1
  • 1
Fomahaut
  • 1,212
  • 1
  • 11
  • 18
0

Use react native's keyboar avoiding view KeyboardAvoidingView and Example Like

import {ScrollView, Text, TextInput, View, KeyboardAvoidingView} from "react-native";

and in render function nest the View and TextInput

<ScrollView style={styles.container}>
          <KeyboardAvoidingView behavior='position'>
                <View style={styles.textInputContainer}>
                  <TextInput
                    value={pin}
                    style={styles.textInput}
                    keyboardType='default'
                    returnKeyType='next'
                    onChangeText={this.handleChangePin}
                    underlineColorAndroid='transparent'
                    placeholder={I18n.t('pin')}/>
                </View>
          </KeyboardAvoidingView>
        </ScrollView>

It will take care of that

Waqas Ahmed
  • 1,321
  • 1
  • 14
  • 23