Hi have been looking into this issue for the last 2 days. I have a web view inside SwipeRefreshLayout which works fine for almost every site but when tried maps.google.com I encountered this weird situation where scrolling the maps triggers SwipeRefresh and the page keeps on reloading().
Any help in this regard is highly appreciated. the sample code is below.
class MainActivity : AppCompatActivity() {
lateinit var browser: WebView
lateinit var swipeLayout : SwipeRefreshLayout
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
browser = findViewById<View>(R.id.webview) as WebView
swipeLayout = findViewById<View>(R.id.swipeRefreshLayout) as SwipeRefreshLayout
browser.settings.loadsImagesAutomatically = true;
browser.settings.javaScriptEnabled = true;
browser.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY;
browser.loadUrl("https://www.google.com/maps");
swipeLayout.setOnRefreshListener {
browser.reload()
swipeLayout.isRefreshing=false
}
browser.webViewClient = (object : WebViewClient() {
override fun onPageFinished(view: WebView, url: String) {
Log.d("Browser", browser.scrollY.toString())
}
})
}
The layout file seems like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
The gif of the issue is attached below

Expected Result: Scrolling Down should only move the maps
Actual Result : SwipeToRefresh is triggered which causes webpage to refresh.