Reputation: 345
just a simple question, should we always use Constraint Layout for everything? why another layout still used today?
I want to make a simple login layout like this, should I use Linear Layout or Constraint Layout?
usually, I make every layout with Constraint Layout but my friend told me to use Linear Layout for the login, is it wrong if I use Constraint Layout? thanks before!
Upvotes: 14
Views: 10188
Reputation: 575
I would say ConstraintLayout is more versatile and has better performance compared to RelativeLayout, But LinearLayout has its own significance in android you can specify weights of view using LinearLayout and for complex UIs I would say going with ConstarintLayout is a better option because of its performance and in ConstarintLayout you can specify the view positions, heights, widths, margins and paddings based on screen sizes rather than hard coding the values to fixed dp
https://android.jlelse.eu/constraint-layout-performance-870e5f238100
The above link gives more overview of LinearLayout vs ConsrainLayout performances.
Upvotes: 4
Reputation: 53
No it it's depends on your need, if you want to make complex layout and want to make them responsive then you can.
Upvotes: 0
Reputation: 1074
ConstraintLayout helps you to avoid using nested layouts and it causes better performance. it's not wrong to use it for everything but if you know that you are not going to have nested layouts, for example, three Textview
s respectively, you can use LinearLayout. ConstraintLayout needs more XML code than LinearLayout for simple structures, and using LinearLayout is better for these situations.
Upvotes: 16