Reputation: 147
I'm testing my layout on my phone and I can feel certain lag the moment I click to open the fragment of this layout.
My layout is exactly like this, and beyond this, i use many linear layouts. My main question is what is weighing more. I believe that is the big quantity of CardViews, but i need to use them for the layout harmony. Someone can indicate something to do about it?
OBS: the blue CardView is to put the title.
Upvotes: 0
Views: 640
Reputation: 62831
Take a look at Optimizing Layout Hierarchies for some tips on what to look for in your layout that may be inefficient. Consider using the newer ConstraintLayout
for some or all of your layout structure. It is billed as being flatter and faster than some other layouts but there is a learning curve. RelativeLayout is another to consider.
Optimizing Layout Hierarchies
It is a common misconception that using the basic layout structures leads to the most efficient layouts. However, each widget and layout you add to your application requires initialization, layout, and drawing. For example, using nested instances of LinearLayout can lead to an excessively deep view hierarchy. Furthermore, nesting several instances of LinearLayout that use the layout_weight parameter can be especially expensive as each child needs to be measured twice. This is particularly important when the layout is inflated repeatedly, such as when used in a ListView or GridView.
Upvotes: 4