Performance issue while using BlurView in RecyclerView items
See original GitHub issuePlease include:
- 1.6.6
- Pixel 2 API 30
- Lagging occurs when using blurview in recyclerview. Every recyclerview item has a blurview. I setup blurview in onBindViewHolder method.
- Xml and blurview setup
// CustomRecyclerViewAdapter.kt
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
blurView.setupWith(rootBlurView)
.setBlurAlgorithm(renderScriptBlur)
.setBlurRadius(4f)
.setHasFixedTransformationMatrix(false)
}
// item_recyclerview.xml
<FrameLayout
android:id="@+id/rootBlurView"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginHorizontal="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<eightbitlab.com.blurview.BlurView
android:id="@+id/blurView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:blurOverlayColor="#78ffffff"/>
</FrameLayout>
- Stacktrace in case of a crash There isn’t any crash only occurs lagging and slow performance while scrolling recyclerview. What is the correct way setup BlurView ? Where can i setup BlurView ?
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Recycler View Blur and Repeat Issue - Stack Overflow
Update-1 i tried using setHasSizeFixed(true) because the adapter data wont change the size of my views all are 90dp height. Not Solved the ......
Read more >Slow rendering - Android Developers
RecyclerView or ListView: layout / draw taking too long. For issues with draw and layout, see the sections on Layout and Rendering Performance....
Read more >How can I increase the performance of WebViews ... - Reddit
It looks like you're showing a video in each recyclerview item. I would advise you to do it differently: try to parse the...
Read more >Must Have Libraries | CodePath Android Cliffnotes
ChipsLayoutManager - RecyclerView's LayoutManager which moves item to the next line when no space left on the current. Can represent google material chips ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can suggest you to make list item much simpler, right now it has plenty of redundant Views that serve no purpose. Something like that, just add elevation and rounded corners drawable to the ConstraintLayout.
Items will inflate faster and also BlurView will have much less work to do. Generally, try to keep your View hierarchy simple and set the root of the BlurView as close as possible.
This will not completely fix your problem, because as I said, having multiple BlurViews like this is a performance hit no matter what.
You can also try to create a custom LinearLayoutManager and override
calculateExtraLayoutSpace
to sort of preload off-screen Views of the list because during fast scrolling RecyclerView can create additional ViewHolders, which is a heavy operation with a BlurView. This trick, in theory, can pre-create enough ViewHolders on start when scrolling is not yet started.But your best bet would be not to use it in the list
Unfortunately, when i’m trying to real project, it is not working as expected. Because i have to use Coordinator layout and cardview in my view holder. I can’t fix the problem yet but i will write below this issue if there is an improvent.