Answer the question
In order to leave comments, you need to log in
What's with the performance of RelativeLayout / ConstraintLayout?
Hello!
I have one list (RecyclerView) where each item has a rather complex layout (about 40 linearlayouts, textviews, etc.)
It is laid out rather clumsily - LinerLayout and TableLayout are everywhere (this is generally the first layout I have made, do not blame me).
Now I'm limiting it, and now I'm thinking of using RelativeLayout / ConstraintLayout.
Question: are they more productive than a bunch of nested LinearLayouts (in some places with given layout_weight)?
Because now, on older phones, scrolling through the list sometimes slows down, not very noticeable, but not pleasant.
Answer the question
In order to leave comments, you need to log in
Relative/Constraint will be faster than a bunch of Linears with weights. The weights are important here, as they give a second pass through Linear's children, and negate its simplicity. Nesting is always bad.
In fact, I can express an unpopular opinion - if there is a complex layout inside the Recycler, and this layout is not generalized, but very specific, then it makes sense to think about making it custom. That is, inherit from ViewGroup, add a view (addView) and implement onMeasure/onLayout. Done right, it will be 100% faster than any general purpose layout.
For myself, I deduced a rule of thumb - there is no place for Constraint inside Recycler. Brakes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question