23

If I have just a single LinearLayout with a few items in it, then what effects will be of replacing it with ConstraintLayout

<LinearLayout>
   <TextView>
   <TextView>
   <TextView>
</LinearLayout>

vs

<ConstraintLayout>
   <TextView>
   <TextView>
   <TextView>
</ConstraintLayout>

Are there any differences in their efficiencies?

n.arrow001
  • 1,090
  • 3
  • 10
  • 28
  • Do you mean being more efficient in terms of memory consumption or time needed to layout the views? If there just a handful of views, I would probably prefer RelativeLayout (though not being part of your question ;-)), which has always been praised as being efficient. And keep in mind that ConstraintsLayout comes as an additional lib whereas both LinearLayout and RelativeLayout are builtin. –  Mar 29 '18 at 10:46
  • By efficient I mean time needed to layout the views. Adding a lib is not a concern. – n.arrow001 Mar 29 '18 at 11:28

1 Answers1

27

For such a simple layout with no nesting and only 3 children TextView, LinearLayout is the best on conceptual complexity, on performance, on drag and drop user interface of Android Studio, on XML lines, on kB size of the app. Maybe I forgot something, but I would not dare to waste time and mess things with any other layout than the LinearLayout in this case.

Zanna
  • 676
  • 9
  • 13