keyboardAvoidingView键盘顶部白色未在React本机代码中删除

zbdgwd5y  于 2023-01-31  发布在  React
关注(0)|答案(1)|浏览(130)

我试图删除白色是目前在键盘是开放的,而运行react本机代码,我已经尝试使用“adjustResize”,“adjustPan”,“adjustNothing”在AndroidManifest.xml文件和keyboardVerticalOffset给予基于platform.选择和行为也给予填充,高度这些是我试图删除我的代码.以上代码和样式我正在使用,请查找问题并解决我的问题EmulatorImage KeyboardIssue

<SafeAreaView
      style={{
        backgroundColor: 'white',
        height: windowHeight,
      }}>
 <LinearGradient
        colors={['#234590', '#0093ad', 'white', 'white']}
        locations={[0, 0.1, 0.2, 0.5]}>
      <View
        style={{
          backgroundColor: 'white',
          marginTop: windowHeight * 0.065,
          // height: windowHeight - (windowHeight * 0.065) - (windowWidth * 0.042),
          borderTopRightRadius: windowHeight * 0.032,
          borderTopLeftRadius: windowHeight * 0.032,
          padding: windowWidth * 0.042,
        }}>
        <KeyboardAvoidingView
          enabled
          keyboardVerticalOffset={Platform.select({ios: 80, android: 100})}
          behavior={Platform.OS === 'ios' ? 'padding' : null}>
          <ScrollView>
            <View
              style={{
                borderRadius: TextFieldCornerRadius,
                height: TextFieldHeight,
                borderColor: '#d9d9d9',
                backgroundColor: 'white',
                borderWidth: 1,
                flexDirection: 'row',
                justifyContent: 'space-between',
              }}>
              <TextInput
                style={{
                  paddingLeft: windowWidth * 0.03,
                  paddingRight: windowWidth * 0.03,
                  paddingVertical: 0,
                  flex: 1,
                  fontSize: TextFieldFontSize,
                }}
              />
            </View>
          </ScrollView>
        </KeyboardAvoidingView>
      </View>
 </LinearGradient>
    </SafeAreaView>;
waxmsbnn

waxmsbnn1#

使用KeyboardAvoidingView,您可以这样做,以避免输入字段被隐藏的问题。

<KeyboardAvoidingView
        behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
        style={{ flex: 1 }}>
<View style={{ flex: 1 }}>
 // your code here
</View>
<KeyboardAvoidingView/>

我已使用RN 0.70.5对此进行了测试

相关问题