android / codelab-constraint-layout

Constraint Layout Codelab
https://codelabs.developers.google.com/codelabs/constraint-layout/
Apache License 2.0
471 stars 242 forks source link

2.0.0-beta3 Visibility of view to GONE also hides WebView underneath #78

Open Onlinedispatcher opened 4 years ago

Onlinedispatcher commented 4 years ago

Currently: We a ConstraintLayout with a webview and a image view. The image view is directly laying over the webview, in order to show a placeholder image, until the webview has finished loading:

<androidx.constraintlayout.widget.ConstraintLayout 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">

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:background="@color/blue_10"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/webview_mask"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:background="@color/blue_10"
        android:src="@drawable/loading_image"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

As soon as the webview has finished loading, the visibility of webview_mask is set to GONE.

private WebViewClient createWebViewClient() {
        return new WebViewClient() {
            public void onPageFinished(WebView view, String url) {
                mWebViewMask.setVisibility(View.GONE);
            }
        };
    }

Expected: With constraintLayout 1.1.3 this is working without any issues. With 2.0.0-beta3 setting the visibility of the mWebViewMask to GONE, also sets height and weight of the webview underneath to 0. Remark: By setting the visibility to INVISIBLE instead of GONE, the webview below is visible again. But this should also work with GONE, as the webview is still there.