当Web内容响应中包含iframe元素且高度设置为100%时,NestedScrollView内的WebView不会滚动

the*_*ger 7 iframe android webview

我有一个Fragment显示的地方WebView.所述Activity含有所述片段具有CoordinatorLayout作为其父.我想Toolbar在用户滚动时折叠WebView.

活动布局

    <android.support.design.widget.CoordinatorLayout android:id="@+id/cordinator_layout"
                                                 xmlns:android="http://schemas.android.com/apk/res/android"
                                                 xmlns:app="http://schemas.android.com/apk/res-auto"
                                                 android:layout_width="match_parent"
                                                 android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/topic_tile_height"
        app:layout_behavior="android.support.design.widget.NewshuntAppBarLayoutBehavior">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/topic_tile_collapsing_toolbar"
            app:layout_scrollFlags="scroll|enterAlways">

            <include layout="@layout/actionbar_news"/>

        </android.support.design.widget.CollapsingToolbarLayout>

        <android.support.design.widget.TabLayout
            android:id="@+id/category_tabs"
            android:layout_width="match_parent"
            android:layout_height="@dimen/topic_slidingtablayout_height"
            android:layout_gravity="bottom"
            android:contentDescription="@string/newspaper_category_tabs"
            android:paddingTop="@dimen/topics_sliding_tab_margin_top"/>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/news_list_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:contentDescription="@string/categories_pager"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

建议的解决方案是在NestedScrollView中使用WebView. 片段的XML布局如下.

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/category_webitem_container"
    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">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">
        <WebView
            android:id="@+id/web_item_content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </WebView>
    </android.support.v4.widget.NestedScrollView>

</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

当要在WebView中加载的响应是简单的HTML时,这很好.但是,如果响应包含iframe元素,则WebView仅填充视图端口.我无法滚动WebView.

以下是WebView不滚动的示例响应.这里的高度为100%.如果我获得1000dp等固定高度,我可以滚动WebView.但我不会从服务器获得固定的高度.

"content":"<html>\r\n<head>\r\n\t<title></title>\r\n</head>\r\n<body>\r\n<div><iframe height=\"100%\" src=\"https://sportscafe.in/s3/sc-s3-static-mum.sportscafe.in/kwc/en_fixtures.html\" width=\"100%\"></iframe></div>\r\n</body>\r\n</html>\r\n"
Run Code Online (Sandbox Code Playgroud)

虽然WebView中有更多内容,但我无法将其滚动到3月29日的文本之外

在此输入图像描述