Can't zoom the webview under swipe to refresh

半城伤御伤魂 提交于 2020-07-27 03:31:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!