android - ScrollView中的WebView在向上滑动时调用refreshControl React Native Android一直

标签 android react-native webview scrollview pull-to-refresh

我在 React Native 应用程序的 ScrollView 中有一个 WebView。 ScrollView 具有刷新控制属性,因此当我到达应用程序顶部时,我可以刷新 WebView。

问题是:我滚动 WebView 没有问题,但是每当我向上滑动到页面顶部时,无论我在页面的末尾、中间还是开头,都没有关系,始终会触发刷新控件。

当scrollY: 0且scrollY始终为0时,会触发RefreshControl,因为滚动的不是ScrollView而是WebView,所以ScrollView始终为scrollY: 0。

我已经在 WebView 和 ScrollView 上尝试了 rollEnabled 属性,但没有成功。

以下是代码现在的样子:

<View style={{flex: 1}}>
    <ScrollView
      contentContainerStyle={{flex: 1}}
      refreshControl={
        <RefreshControl
          refreshing={this.state.refreshing}
          onRefresh={this._onRefresh.bind(this)}
        />
      }
    >
      <WebView
        ref="webview"
        source={{uri: initialUrl}}
      />
    </ScrollView>
</View>

我已经删除了所有 Prop 以尝试重新开始,但我总是遇到同样的问题。在 iOS 上它工作正常,没有这个问题。

是的,我在这个母 View 中确实还有其他东西。

最佳答案

奇怪的是,我从 contentContainerStyle 中删除了样式,并且效果很好。只是想我会删除可能妨碍功能的额外内容。也许这是一个错误,但现在尽量避免使用 Flexbox 设置。

关于android - ScrollView中的WebView在向上滑动时调用refreshControl React Native Android一直,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50570920/

相关文章:

javascript - Redux 在功能组件中分派(dispatch)后没有立即更新

javascript - Android WebView AJAX 沙箱

android - XML Inflater 没有看到任何 View ?

android - 在 RelativeLayout 中水平居中 RecyclerView

javascript - 在 React Native View 上强制 onLayout

javascript - React Native Controller FormData TextInput 不重置

java - 如何在 Java 中使用 WebResourceRequest 获取 WebView 的 Url?

android - OkHTTPClient 将 cookie 传递给 Webview

android - 固定位置,100% 高度元素,在移动设备上并不总是 100%

android - 使用安卓模拟器给自己打电话