1

I’m setting up a new component, and the keyboard covers the fields

This is for a new component

<KeyboardAwareScrollView enableOnAndroid={true} extraScrollHeight={50} enableAutomaticScroll={true}>
                    <View style={{ paddingHorizontal: 20 }}>

                        <View>
                            <FloatingLabelInput
                                onRef={(ref) => {
                                    this.inputs['firstName'] = ref
                                }}
                                onSubmitEditing={() => {
                                    this.focusNextField('lastName')
                                }}
                                label={i18n.t('t_driver_registration_first_name_label')}
                                onChangeText={(text) => this.onChangeInputText('firstName', text)}
                                keyboardType='default'
                                maxLength={20}
                                value={form.firstName}
                                labelStyle={Style.inputLabel}
                                basicColor={GStyle.GREEN}
                                inputTextColor={Color(GStyle.BLACK).alpha(.7)}
                                editable={mode !== DriverFormMode.EDIT}
                            />

I expect the keyboard will not cover my fields.

pasignature
  • 577
  • 1
  • 6
  • 13
Bob
  • 123
  • 3
  • 10

1 Answers1

0

Wrap your view in this to scroll automatically on input focus. Do:

<KeyboardAvoidingView style={{ flex: 1, flexDirection: 'column',justifyContent: 'center',}} behavior="padding" enabled   keyboardVerticalOffset={100}>
    <ScrollView>
        <View style={Styles.row}>
                //your view
        </View>
    </ScrollView>
</KeyboardAvoidingView>

<View style={Styles.row}> This is just a Stylesheet e.g. Create a new StyleSheet:

const Styles = StyleSheet.create({
  row: {
    borderRadius: 4,
    borderWidth: 0.5,
    borderColor: '#d6d7da',
  },
  title: {
    fontSize: 19,
    fontWeight: 'bold',
  },
  activeTitle: {
    color: 'red',
  },
});

Use a StyleSheet:

<View style={Styles.row}>
  <Text style={[Styles.title, this.props.isActive && styles.activeTitle]} />
</View>
David Jesus
  • 1,981
  • 2
  • 29
  • 34
pasignature
  • 577
  • 1
  • 6
  • 13