【发布时间】:2020-11-03 07:41:16
【问题描述】:
我在 swipetorefresh 布局下进行了 webview。我无法在 webview 中平滑缩放。但是,如果我删除 swipetorefresh 那么它会完美缩放。 这是布局:
<?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成为SwipeRefreshLayout的直接子级? -
@RezaBigdeli 也没有用。 :(
标签: android webview zooming swiperefreshlayout