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

Add fading effect in blurview top and remove flickering when view is passed through it. #215

Open
AasthaDoshi opened this issue May 6, 2024 · 7 comments

Comments

@AasthaDoshi
Copy link

AasthaDoshi commented May 6, 2024

Can we apply gradient blur into this to such extent that it gives a shadow effect on the view which is passed through it from top? Also get rid of blurview flickering when view passed through it?

@Dimezis
Copy link
Owner

Dimezis commented May 6, 2024

You should be able to do it with a custom BlurAlgorithm

@AasthaDoshi
Copy link
Author

AasthaDoshi commented May 7, 2024

@Dimezis Do you have any example or idea to proceed with this? Actually what I want is that when any text or view passed through BlurView then it should show a shadowlayer on top. Just like attached image.

@Dimezis
Copy link
Owner

Dimezis commented May 7, 2024

Subclass the BlurView and draw a transparent gradient mask in draw() to fade the top edge

@AasthaDoshi
Copy link
Author

@Dimezis Are you aware about any library with this solution? I tried to apply outer blurmaskfilter but it did not work for me.

@Dimezis
Copy link
Owner

Dimezis commented May 7, 2024

Are you aware about any library with this solution?

I'm not, but you don't necessarily need any additional libraries for this. Something like this will probably work https://stackoverflow.com/questions/50556388/how-to-make-a-transparent-alpha-gradient-mask-to-make-one-layer-fade-into-tran

@AasthaDoshi
Copy link
Author

Thanks @Dimezis!
Let me try this solution as well.

@AasthaDoshi
Copy link
Author

Hi @Dimezis,
Thanks for the hint again!

After applying some additional adjustments I was able to achieve desired result up to some extent. But one question though why does this blur view flickers when any item of recyclerview passed through it. When user scroll normally or fastly then no flickering is noticed but on slow scroll it is noticeable.

<FrameLayout
     android:id="@+id/clBlurRoot"
     android:layout_width="match_parent"
     android:layout_height="0dp"
     app:layout_constraintBottom_toBottomOf="parent"
     app:layout_constraintTop_toTopOf="@id/glBanner">

     <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/rv_menu_list"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:background="@color/transparent"
         android:clipToPadding="false"
         android:overScrollMode="never"
         android:scrollbars="vertical"
         tools:itemCount="4"
         tools:listitem="@layout/item_navigation" />

     <com.klaraui.utilities.blur.FadingEdgeLayout
         android:id="@+id/fading_edge_layout"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_gravity="bottom"
         app:fel_edge="top"
         app:fel_size_top="45dp"
         app:layout_constraintBottom_toBottomOf="parent">

         <com.klaraui.utilities.blur.BlurView
             android:id="@+id/blurView"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             app:layout_constraintBottom_toBottomOf="parent">

                              <--Chid Content-->
                              
          </com.klaraui.utilities.blur.BlurView>

     </com.klaraui.utilities.blur.FadingEdgeLayout>

 </FrameLayout>
 val radius = 5f
 val decorView = window.decorView
 val windowBackground = decorView.background
 binding.blurView.setupWith(binding.clBlurRoot as ViewGroup) // or RenderEffectBlur
.setFrameClearDrawable(windowBackground) // Optional
.setBlurRadius(radius)

@AasthaDoshi AasthaDoshi changed the title Can we apply gradient blur into this to such extent that it gives a shadow effect on the view which is passed through it from top? Add fading effect in blurview top and remove flickering when view is passed through it. May 13, 2024
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