【问题标题】:Different behaviours between platforms in react-native-keyboard-aware-scroll-viewreact-native-keyboard-aware-scroll-view中平台之间的不同行为
【发布时间】:2020-01-20 18:24:27
【问题描述】:

我的库 react-native-keyboard-aware-scroll-view 有问题。

我已经在 Android 中配置了 windowSoftInputMode="adjustPan" 并且我正在使用 enableOnAndroid 并且使用相同的代码,当我在底部使用 KeyboardAwareScrollView 之外的固定元素时,我有不同的行为。

问题在于,在 iOS 中,我有一个额外的填充,其高度与外部组件的高度相同。

这是我的测试代码:

import React from 'react';
import {
  View,
  Text,
  TextInput,
} from 'react-native';
import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view'

const App = () => {
  return (
    <>
    <KeyboardAwareScrollView enableOnAndroid extraHeight={0}>
        <View style={{height: 600}}/>
        <TextInput 
        placeholder='hey' 
        style={{
          width: '100%',
          borderWidth: 1,
          height: 60
        }} />
    </KeyboardAwareScrollView>
    <View style={{backgroundColor: '#f0f', paddingVertical: 20, width: '100%'}}>
      <Text>Hello, I'm bottom View</Text>
    </View>
    </>
  );
};

export default App;

这就是行为:

iOS

如您所见,TextInput 和 Keyboard 之间的高度填充比 Android 中的要大,并且正好等于底部 View 的高度。

安卓

我该如何解决这个问题?在此先感谢:)

测试于:

iOS:12.2

Android:API 28

RN:0.59.10 和 0.60.5

RNKASV:0.9.1

【问题讨论】:

    标签: android ios react-native


    【解决方案1】:

    使用extraScrollHeight 否定解决了这个问题。

    【讨论】:

    • 仍然得到与最初问题完全相同的行为。也更改了 AndroidManifest.xml (windowSoftInputMode="adjustPan")。我正在使用你的代码。
    猜你喜欢
    • 2019-04-02
    • 2017-03-16
    • 1970-01-01
    • 2020-09-17
    • 1970-01-01
    • 1970-01-01
    • 2020-02-16
    • 1970-01-01
    • 2023-02-01
    相关资源
    最近更新 更多