prs_wjy
prs_wjy

Reputation: 345

Should I always use ConstraintLayout for everything?

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?

enter image description here

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

Answers (3)

Spiker
Spiker

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

Aditya panther
Aditya panther

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

houman.sanati
houman.sanati

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 Textviews 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

Related Questions