Невозможно создать слой для WebView с NestedScrollView - PullRequest
0 голосов
/ 10 июня 2019

Я добавляю NestedscrollView в веб-просмотр, чтобы можно было скрыть / показать панель инструментов, когда пользователь выполняет прокрутку. Действие работает нормально, пока я не добавил NestedScrollView, чтобы можно было выполнять скрытие / показ движения. В данный момент я получаю сообщение об ошибке и не знаю, как это исправить.

java.lang.IllegalStateException: Unable to create layer for WebView, size 720x12996 exceeds max size 8192

Это мой xml

 <androidx.coordinatorlayout.widget.CoordinatorLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:app="http://schemas.android.com/apk/res-auto">
        <LinearLayout
            android:id="@+id/ly_webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:background="@android:color/background_light">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="25dp"
                android:background="@color/negro">
            </RelativeLayout>

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

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <androidx.core.widget.NestedScrollView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="fill_vertical"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior">
                    <WebView
                        android:id="@+id/webview_browser"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />
                </androidx.core.widget.NestedScrollView>

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/rv_web_items"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical"
                    android:visibility="gone"
                    android:layout_marginTop="@dimen/margin_standard"/>

            </RelativeLayout>
        </LinearLayout>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>

Generic_toolbar_browser

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.appbar.AppBarLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/home_appbarLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar_browser"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/actionBarSize"
        app:layout_collapseMode="pin"
        app:titleTextColor="@color/white"
        app:theme="@style/ThemeOverlay.AppCompat.ActionBar"
        app:layout_scrollFlags="scroll|enterAlways"
        android:background="@color/blanco">

        .....

    </androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>

1 Ответ

0 голосов
/ 10 июня 2019

A WebView может прокручиваться самостоятельно. Не должно быть необходимости размещать его внутри NestedScrollView. Это, вероятно, уменьшит размер WebView. Не беспокойтесь о app:layout_behavior="@string/appbar_scrolling_view_behavior", он должен работать и на WebView (хотя существуют крайние случаи, которые могут быть сложны в настройке). Э.Г.

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <WebView
            android:id="@+id/webview_browser"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_web_items"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:visibility="gone"
            android:layout_marginTop="@dimen/margin_standard"/>

    </RelativeLayout>

Если это не сработает, взгляните на родителей WebView. Один из них, вероятно, слишком большой (= это высота). Поэтому постарайтесь не выходить за пределы высоты экрана

...