video disappears when setting match_parent in webview

Viewed 23

I have a webview in which video is played, if you set the size of the webview, for example, 200 to 200, then everything is ok, but when installed programmatically

                android:layout_width="match_parent"
                android:layout_height="wrap_content"

then the video disappears from the screen, the screen becomes black. While the stream from the video continues to play as the music from the video continues to play. How I can fix it ?

            <androidx.core.widget.NestedScrollView
            android:id="@+id/webScrollContainer"
            android:layout_width="200sp"
            android:layout_height="200sp"
            android:fillViewport="true"
            android:visibility="@{playerType == PlayerViewType.WEB ? View.VISIBLE : View.GONE}"
            tools:visibility="visible">

            <com.onixcamera.ui.view.custom.SizableWebView
                android:id="@+id/testWebView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/black"
                android:fillViewport="true"
                android:focusable="true"
                android:isScrollContainer="false"
                android:visibility="visible"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                app:layout_scrollFlags="scroll|exitUntilCollapsed" />

        </androidx.core.widget.NestedScrollView>

...

        binding.testWebView.loadUrl(url)
1 Answers

Webview inside a NestedScrollView is generell bad idea and causes a lot of trouble. You cannot just use layout_height=match_parent inside of the ScrollView.

Either restrict the Webview directly, by layout_height=200px (and not the NestedScrollView) or let the Webview handle scrolling and remove the NestedScrollView.

When you remove the ScrollView, you can use layout_height=match_parent for the Webview (assuming it is in a suitable container layout, e.g. LinearLayout)

Related