Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlurView is not blurring well enough text and some images #219

Open
hmmmk opened this issue Aug 14, 2024 · 11 comments
Open

BlurView is not blurring well enough text and some images #219

hmmmk opened this issue Aug 14, 2024 · 11 comments

Comments

@hmmmk
Copy link

hmmmk commented Aug 14, 2024

  1. Lib version 2.0.5
  2. Pixel 7 Pro, Android 14

So the issue is that somehow BlurView is not blurring properly some TextViews and images (ImageView). And I can not understand how to fix this. You can see that in the attached screenshot. As for the types of elements it's just TextView and ImagView, but the BottomNavigationView also contains lotties in some of the buttons and the background of it is ShapeDrawable.

I tried to look over the docs of the lib and samples and tried to use setFrameClearDrawable() with background of parentFragment rootView, but this didn't change nothing. Can you tell me what am I doing wrong and is there any way for fixing this?

2024-08-14 17 26 50

@Dimezis
Copy link
Owner

Dimezis commented Aug 14, 2024

What content root do you pass to the BlurView?
Does the same happen if you pass the activity's window decorView?

@hmmmk
Copy link
Author

hmmmk commented Aug 14, 2024

What content root do you pass to the BlurView? Does the same happen if you pass the activity's window decorView?

I'm doing it like this

val fragment = requireParentFragment() val rootView = fragment.requireView() as ViewGroup

And I'm doing it in BottomSheetDialogFragment. So basically rootView of a parent fragment. I didn't try it with activity's decorView

@hmmmk
Copy link
Author

hmmmk commented Aug 14, 2024

@Dimezis just tried to use fragment.window.decorView.findViewById<ViewGroup>(android.R.id.content) as root view, same thing

@Dimezis
Copy link
Owner

Dimezis commented Aug 14, 2024

What's the size and position of the BlurView?
Can you verify it's where it's supposed to be in the Layout Inspector?
Do you animate BlurView's position or its parent? If so, how?

@hmmmk
Copy link
Author

hmmmk commented Aug 15, 2024

@Dimezis okay, I think it will be better to share an xml file with you

`

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:background="@color/gray_tem_text">

<eightbitlab.com.blurview.BlurView
    android:id="@+id/bgView"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:background="@drawable/bg_rounded_top_rectangle"
    app:blurOverlayColor="#CC000000"
    app:layout_constraintBottom_toBottomOf="parent"
    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">

        <eightbitlab.com.blurview.BlurView
            android:id="@+id/blurClose"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="8dp"
            android:background="@drawable/oval_shape"
            app:blurOverlayColor="#CC000000"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <ImageView
                android:id="@+id/closeIv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                android:src="@drawable/ic_close" />
        </eightbitlab.com.blurview.BlurView>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/firstOptionCl"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="56dp"
            android:layout_marginEnd="6dp"
            android:background="@drawable/bg_rounded_rectangle"
            android:clickable="true"
            android:focusable="true"
            app:layout_constraintBottom_toTopOf="@+id/thirdOptionCl"
            app:layout_constraintDimensionRatio="1:1"
            app:layout_constraintEnd_toStartOf="@id/multiplePurchaseCl"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/coinAnimatedIv">

            <ImageView
                android:id="@+id/firstOptionIv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="22dp"
                android:src="@drawable/ic_coin_first_option"
                app:layout_constraintBottom_toTopOf="@+id/firstOptionPriceTv"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_chainStyle="packed" />

            <TextView
                android:id="@+id/firstOptionPriceTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="21dp"
                android:fontFamily="@font/gilroy_extrabold"
                android:text="100 000"
                android:textColor="#FDC903"
                android:textSize="20sp"
                app:layout_constraintBottom_toTopOf="@+id/firstOptionBtn"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/firstOptionIv" />

            <com.google.android.material.button.MaterialButton
                android:id="@+id/firstOptionBtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:layout_marginBottom="16dp"
                android:backgroundTint="#FDC903"
                android:fontFamily="@font/gilroy_extrabold"
                android:text="1 999 ₽"
                android:textColor="@color/black"
                app:cornerRadius="12dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/firstOptionPriceTv" />
        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/multiplePurchaseCl"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginStart="6dp"
            android:layout_marginEnd="16dp"
            android:background="@drawable/bg_rounded_rectangle"
            android:clickable="true"
            android:focusable="true"
            app:layout_constraintDimensionRatio="1:1"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@id/firstOptionCl"
            app:layout_constraintTop_toTopOf="@id/firstOptionCl">

            <ImageView
                android:id="@+id/secondOptionIv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="22dp"
                app:layout_constraintBottom_toTopOf="@+id/secondOptionPriceTv"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_chainStyle="packed"
                android:src="@drawable/ic_coin_first_option" />

            <TextView
                android:id="@+id/secondOptionPriceTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="21dp"
                android:fontFamily="@font/gilroy_extrabold"
                android:text="200 000"
                android:textColor="#FDC903"
                android:textSize="20sp"
                app:layout_constraintBottom_toTopOf="@+id/secondOptionBtn"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/secondOptionIv" />

            <com.google.android.material.button.MaterialButton
                android:id="@+id/secondOptionBtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:layout_marginBottom="16dp"
                android:backgroundTint="#FDC903"
                android:fontFamily="@font/gilroy_extrabold"
                android:text="4 999 ₽"
                android:textColor="@color/black"
                app:cornerRadius="12dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/secondOptionPriceTv" />
        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/thirdOptionCl"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:layout_marginEnd="6dp"
            android:background="@drawable/bg_rounded_rectangle"
            android:clickable="true"
            android:focusable="true"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintDimensionRatio="1:1"
            app:layout_constraintEnd_toStartOf="@id/fourthOptionCl"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/firstOptionCl">

            <ImageView
                android:id="@+id/thirdOptionIv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="22dp"
                android:src="@drawable/ic_coin_third_option"
                app:layout_constraintBottom_toTopOf="@+id/thirdOptionPriceTv"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_chainStyle="packed" />

            <TextView
                android:id="@+id/thirdOptionPriceTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="21dp"
                android:fontFamily="@font/gilroy_extrabold"
                android:text="300 000"
                android:textColor="#FDC903"
                android:textSize="20sp"
                app:layout_constraintBottom_toTopOf="@+id/thirdOptionBtn"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/thirdOptionIv" />

            <com.google.android.material.button.MaterialButton
                android:id="@+id/thirdOptionBtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:layout_marginBottom="16dp"
                android:backgroundTint="#FDC903"
                android:fontFamily="@font/gilroy_extrabold"
                android:text="10 999 ₽"
                android:textColor="@color/black"
                app:cornerRadius="12dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/thirdOptionPriceTv" />
        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/fourthOptionCl"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginStart="6dp"
            android:layout_marginEnd="16dp"
            android:background="@drawable/bg_rounded_rectangle"
            android:clickable="true"
            android:focusable="true"
            app:layout_constraintDimensionRatio="1:1"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@id/thirdOptionCl"
            app:layout_constraintTop_toTopOf="@id/thirdOptionCl">

            <ImageView
                android:id="@+id/fourthOptionIv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="22dp"
                app:layout_constraintBottom_toTopOf="@+id/fourthOptionPriceTv"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_chainStyle="packed"
                android:src="@drawable/ic_coin_fourth_option" />

            <TextView
                android:id="@+id/fourthOptionPriceTv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="21dp"
                android:fontFamily="@font/gilroy_extrabold"
                android:text="500 000"
                android:textColor="#FDC903"
                android:textSize="20sp"
                app:layout_constraintBottom_toTopOf="@+id/fourthOptionBtn"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/fourthOptionIv" />

            <com.google.android.material.button.MaterialButton
                android:id="@+id/fourthOptionBtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:layout_marginBottom="16dp"
                android:backgroundTint="#FDC903"
                android:fontFamily="@font/gilroy_extrabold"
                android:text="15 999 ₽"
                android:textColor="@color/black"
                app:cornerRadius="12dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/fourthOptionPriceTv" />
        </androidx.constraintlayout.widget.ConstraintLayout>

        <ImageView
            android:id="@+id/coinAnimatedIv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintBottom_toTopOf="@+id/firstOptionCl"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.5"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_chainStyle="packed"
            tools:srcCompat="@tools:sample/avatars" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</eightbitlab.com.blurview.BlurView>

</androidx.constraintlayout.widget.ConstraintLayout>`

This is the layout. And if you ask about animations - no. At least I'm not doing it manually. I mean the dialog itself is being animated when dragging, but it's controlled by BottomSheetDialogFragment, not my code.

@Dimezis
Copy link
Owner

Dimezis commented Aug 15, 2024

Don't know how to help you.

Judging by the screenshot, the blur probably didn't get updated when you dragged the sheet.

  • Make sure you're using 2.0.5, since I saw you're declaring the same dependency twice in your build.gradle
  • Pass the topmost Activity root (activity.window.decorView)
  • Try debugging blur updates when dragging the sheet and see if updateBlur gets called.

@hmmmk
Copy link
Author

hmmmk commented Aug 15, 2024

Don't know how to help you.

Judging by the screenshot, the blur probably didn't get updated when you dragged the sheet.

  • Make sure you're using 2.0.5, since I saw you're declaring the same dependency twice in your build.gradle
  • Pass the topmost Activity root (activity.window.decorView)
  • Try debugging blur updates when dragging the sheet and see if updateBlur gets called.

I don't think that's the issue because it is blurring image in the middle of the screen. But the top part and the bottom part is not blurred

@hmmmk
Copy link
Author

hmmmk commented Aug 15, 2024

The thing is that I noticed this issue not only in this case. Some time ago, I tried to put blur in the background of BottomNavigationView with a RecyclerView underneath it, and there were the same issue: some TextView's and ImageView's were not blurred at all

@Dimezis
Copy link
Owner

Dimezis commented Aug 15, 2024

But the top part and the bottom part is not blurred

The bottom part is not blurred because once again, you're passing the root that doesn't include the bottom bar.

In any case, I can't help you without a repro sample

@hmmmk
Copy link
Author

hmmmk commented Aug 15, 2024

But the top part and the bottom part is not blurred

The bottom part is not blurred because once again, you're passing the root that doesn't include the bottom bar.

In any case, I can't help you without a repro sample

Can you look into it, if I share access to the sample project?

@Dimezis
Copy link
Owner

Dimezis commented Aug 15, 2024

Sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants