问题
I've webview under swipetorefresh layout. I cannot zoom smoothly in the webview. But, if I remove the swipetorefresh then it is zooming perfectly. This the layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:ignore="MergeRootFrame"
android:keepScreenOn="true">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:scrollbars="vertical"
/>
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</RelativeLayout>
and this the code that I implemented to zoom. It is bearely zooming if we try three four times to zoom but that is also not smooth.
WebSettings settings = this.webView.getSettings();
settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
settings.setDisplayZoomControls(false);
回答1:
Got this one working with changing the height attribute of the underlying Webview.
For NestedScrollView use attribute
android:fillViewport="true"
and for WebView use
android:layout_height="wrap_content"
来源:https://stackoverflow.com/questions/62887229/cant-zoom-the-webview-under-swipe-to-refresh