Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single LinearLayout vs Single ConstraintLayout

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?

like image 345
n.arrow001 Avatar asked Mar 29 '18 10:03

n.arrow001


People also ask

What is the difference between ConstraintLayout and LinearLayout?

ConstraintLayout has flat view hierarchy unlike other layouts, so does a better performance than relative layout. Yes, this is the biggest advantage of Constraint Layout, the only single layout can handle your UI. Where in the Relative layout you needed multiple nested layouts (LinearLayout + RelativeLayout).

Is ConstraintLayout faster than LinearLayout?

More complex layout but results are the same, flat Constraint Layout is slower than nested Linear Layout. I want to pay attention to 2 more things which are more subjective. Creating Constraint Layout takes more time than other layouts. Also introducing changes in existing Constraint Layout is much more time-consuming.

Can we use LinearLayout in ConstraintLayout?

Most of what can be achieved in LinearLayout and RelativeLayout can be done in ConstraintLayout. However, learning the basics of LinearLayout and RelativeLayout is important before trying to understand how to use it with ConstraintLayout.

What is difference between LinearLayout and RelativeLayout?

LinearLayout : is a ViewGroup that aligns all children in a single direction, vertically or horizontally. RelativeLayout : is a ViewGroup that displays child views in relative positions.


1 Answers

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.

like image 69
Zanna Avatar answered Oct 15 '22 04:10

Zanna