Blubber
Blubber

Reputation: 1473

Is Constraint Layout a replacment for all other layouts?

Should I replace all other layouts with Constraint layouts. I heard that maybe it is encouraged to use constraint layout. Is it because the other layouts will be deprecated soon? I was trying to replace nested linear layouts with a constraint layout, and it seemed more difficult using a constraint than just using linear layouts since the chains just got tangled up with each other.

Upvotes: 0

Views: 545

Answers (2)

Serega
Serega

Reputation: 650

You can't and shouldn't replace all other layouts with ConstraintLayouts :) Many standard layouts have much more cool functionality that just relative positioning of subviews - for example you can easy create animated app bar with CoordinatorLayout, but you'll spend much more time to implement this manually with help of ConstraintLayout.

Upvotes: 1

CoderP
CoderP

Reputation: 1371

Definitely Not.

Constraint layout provides more flexibility than relative layouts. So it's an improved version of relative layout (and in some cases linear layout too.).

It works on Flat Hierarchy Model, so it can be of help when you have a view that is nested and complex. Constraint layout will have better performance than nested relative layout.

Another advantage is UI Responsiveness that can be achieved via constraints. So the UI automatically adjusts to the screen. This has been a challenge for developers for a long time trying to create identical look and feel for various resolutions/ screen-sizes. The feature that was missing in relative layouts.

Upvotes: 1

Related Questions