KeyboardAvoidingView 안의 ScrollView 크기 조절하기

Maliethy·2021년 4월 19일
0

1. issue

로그인 화면에서 전화번호 TextInput에서 비밀번호 TextInput을 tab할 때(focus가 이동할 때) KeyboardAvoidingView로 감싼 ScrollView의 크기가 자동조정되지 않는다.
전화번호 TextInput에서 비밀번호 TextInput을 바로 tab하지 않고 (을 이용해) 화면 다른 곳을 클릭해 keyboard를 한 번 내리고 비밀번호 TextInput를 클릭하면 화면이 자동 조정된다.

 <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
      <KeyboardAvoidingView
        behavior="position"
        style={styles.container}
        keyboardVerticalOffset={-220}
        enabled>
        <ScrollView keyboardShouldPersistTaps="never">
          <View style={styles.formLayout}>
            <View style={styles.phoneInputStyle}>
              <View style={styles.inputRowStyle}>
                <FloatingLabelInput
                  value={phone}
                  onChangeText={onChangePhone}
                  keyboardType={'number-pad'}
                  label="전화번호"
                  ...
                />
              </View>
             </View>
            <View style={styles.inputRowStyle}>
              <FloatingLabelInput
                isPassword
                value={password}
                onChangeText={onChangePassword}
                label="비밀번호"
                ....
              />
            </View>
          </ScrollView>
        </KeyboardAvoidingView>
    </TouchableWithoutFeedback>

2. solution

      AndroidManifest.xml설정을 adjustPan으로 바꾼다. 

android:windowSoftInputMode="adjustPan"

profile
바꿀 수 있는 것에 주목하자

0개의 댓글