Issue
One of my activities is freezing and lagging a lot. I tried using profiler but couldn't get much details. Is there any other tool that can help me figure out the cause for the lagging of the activity?
PS - there is a ton of flows and code in activity so no point in posting the code here
Solution
I think you have 2 reasons for lagging:
- You are very often redraw difficult UI in ViewGroup or RecyclerView. In developer options you can enable
Show layout bounds
for inspect this problem. - You make something long in main thread and need to research what can long works in main thread.
Also if your lagging depends with RecyclerView, you need to make simple ViewHolder (make simple UI with one ViewGroup and remove all logic from ViewHolder, for example: string formatting, some math...). Also better to use ListAdapter instead of RecyclerViewAdapter.
Maybe if you will provide more info, I can provide you more recomendations.
Answered By - Andrii Hridin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.