Android Constraintlayout Performance Improvements - Missing In Action
Solution 1:
In order to answer this question, we'll have to take a detour for that.
I am assuming that you have read about how ConstraintLayout
works internally, so let me just stick to the point. Yes, I agree that ConstraintLayout
is slower than LinearLayout
but it's only when the number of child views are less in number.
When you start building larger layouts, say which consist of 20-30 Views, the ConstraintLayout
comes handy. If you'll then use LinearLayout
or any other layout, say RelativeLayout
then you'll end up using multiple child ViewGroups
and your Layout Graph might end up like this
LinearLayout(orientation vertical)
->SomeChildView (let's say a TextView)
->LinearLayout (orientation horizontal)
-> ChilView 1-> ChildView 2-> ImageView
-> ButtonView
->ViewGroup (FrameLayout)
-> ImageView1
-> idk, maybe TextView?
and the list goes on.
Now, with such kind of Layout, traditional ViewGroups
will end up computing more number of views than ConstraintLayout
So, we can come up with a conclusion that, no ViewGroup is perfect!! We just have to use them in accordance to our need..
Bonus!!ConstraintLayout
should be avoided inside RecyclerView
because it calls onMeasure()
multiple times than any other layout.
I once made some research on ConstraintLayout
back then before applying it to my project.
Post a Comment for "Android Constraintlayout Performance Improvements - Missing In Action"