If you want to add progress bar also please look at final code in this blog post.
Web Page not available error in Android WebView(Custom Error page)
Pull to refresh in Webview
activity_webview.xml
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:orientation="vertical">
android:id="@+id/liProgressContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:id="@+id/progressBar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:indeterminate="true" />
android:id="@+id/tvLoadingPercentage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF" />
androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/liProgressContainer">
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
androidx.core.widget.NestedScrollView>
androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111" />