Dimezis / BlurView

Dynamic iOS-like blur of underlying Views for Android
Apache License 2.0
3.52k stars 334 forks source link

ProgressBar under BlurView gets a weird square while animating #156

Open dxshindeo opened 3 years ago

dxshindeo commented 3 years ago

1) Library version

1.6.6

2) Device and OS version

Android 10 (Huawei P20 Pro)

3) Detailed steps to reproduce the issue

Simply put a progressbar under the blurView and after first cycle a sorta cut-out square will show up around the progressbar

progressbar_issue

4) XML layout and code for BlurView setup

    <include
        android:id="@+id/progressbarForm"
        layout="@layout/block_progressbar_primary"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0" />

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/fragmentNavigation"
        android:name="asd.fragments.NavigationFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:translationZ="100dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        tools:layout="@layout/fragment_navigation" />
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/wrapperNavigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent">

    <asd.components.blurview.BlurView
        android:id="@+id/blurView"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        app:blurOverlayColor="@color/white20percent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:id="@+id/navigation"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:baselineAligned="false"
                android:gravity="center"
                android:orientation="horizontal"
                android:weightSum="4"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

               ...

            </LinearLayout>

        </androidx.constraintlayout.widget.ConstraintLayout>

    </asd.components.blurview.BlurView>

</androidx.constraintlayout.widget.ConstraintLayout>
    private void setupBlurView() {
        float radius = 10f;

        View decorView = requireActivity().getWindow().getDecorView();
        //ViewGroup you want to start blur from. Choose root as close to BlurView in hierarchy as possible.
        ViewGroup rootView = (ViewGroup) decorView.findViewById(android.R.id.content);

        //Set drawable to draw in the beginning of each blurred frame (Optional).
        //Can be used in case your layout has a lot of transparent space and your content
        //gets kinda lost after after blur is applied.
        Drawable windowBackground = decorView.getBackground();

        binding.blurView.setupWith(rootView)
                .setFrameClearDrawable(windowBackground)
                .setBlurAlgorithm(new RenderScriptBlur(requireContext()))
                .setBlurRadius(radius)
                .setBlurAutoUpdate(true)
                .setHasFixedTransformationMatrix(true); // Or false if it's in a scrolling container or might be animated
    }
Dimezis commented 3 years ago

What's the type of this progress bar? Default, custom, material? Post your progressbarForm

dxshindeo commented 3 years ago

Sorry, forgot to mention:

<?xml version="1.0" encoding="utf-8"?>
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:indeterminate="true"
    android:indeterminateTint="@color/pink"
    android:indeterminateTintMode="src_in"
    android:progressTint="@color/pink" />