无法在轻扫下缩放 Web 视图以刷新



我在刷新布局下有web视图。我无法在网络视图中平滑缩放。但是,如果我删除滑动刷新,那么它就是完美的缩放。这种布局:

<?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>

这是我实现缩放的代码。如果我们尝试缩放三四次,这是可以忍受的缩放,但这也不平滑。

WebSettings settings = this.webView.getSettings();
settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
settings.setDisplayZoomControls(false);

通过更改底层Webview的高度属性获得了这个。

对于NestedScrollView,请使用属性

android:fillViewport="true"

和用于WebViewandroid:layout_height="wrap_content"

最新更新