首页 > 解决方案 > android WebView溢出:向上滚动时自动触发SwipeRefreshLayout

问题描述

当您使用 overflow:auto 加载 WebView 内容并且它被 SwipeRefreshLayout 包围时,向下滚动效果很好,但向上滚动会触发 SwipeRefreshLayout 的 onRefresh。

 <android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swiperefresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

       <WebView
           android:id="@+id/webview"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" />
 </android.support.v4.widget.SwipeRefreshLayout>

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    browser = findViewById(R.id.webview);
    browser.loadUrl("https://odatv.com/mob.php"); //this is the url where the problem appears
}

此站点中,问题仅出现在手机中,在平板电脑中运行正常。 视频演示 我扩展 WebView 以检查滚动位置,但未调用 onScrollChanged 并且仅在水平滚动时调用 onOverScrolled。

在这种情况下如何使 SwipeRefreshLayout 正常工作?

标签: androidwebviewscrolloverflowswiperefreshlayout

解决方案


推荐阅读