I am just wondering when to choose the CoordinatorLayout over “Traditional” Layouts or are they (or at least some of them) going to be deprecated?
The question ConstraintLayout vs CoordinatorLayout already showed me that the CoordinatorLayout still has its right of existence.
I’d imagine that the FrameLayout is still a better choice than the ConstraintLayout when there is only one child View.
But what’s about the other Layouts?
I am personally so accustomed to writing layouts by hand in xml so transitioning to the ConstraintLayout is very hard for me. Furthermore answers to this questions would really interest me:
Does the ConstraintLayout have better performance then a nested Layout? If it is the case, at which point does this occur (which level of nesting)?
I am just wondering when to choose the CoordinatorLayout over
“Traditional” Layouts or are they (or at least some of them) going to
ConstraintLayout is useful, but (for now) it is not required for Android app development, any
RelativeLayout are. And, because
ConstraintLayout is a
library, you will need to take some additional steps to add it to your project (
com.android.support.constraint:constraint-layout artifact in your
dependencies closure of your module’s build.gradle file), and it
adds ~100KB to the size of your Android app.
I am personally so accustomed to writing layouts by hand in xml so
transitioning to the ConstraintLayout is very hard for me.
Drag and drop GUI builder
Google is trying to make life easier to developers and make they work faster and more productive so they continue improving drag-drop GUI builder. However drag-and-drop gestures, the developer is only
providing you with X/Y coordinates of a widget, based on where the developer
releases the mouse button and completes the drop.
LinearLayout adding widgets is easy. With
RelativeLayout is difficult for GUI bulder to handle drag-drop and probably you will have to dig inside the XML code to get things done.
ConstraintLayout was created with GUI building in mind, to make it a bit easier to
infer the right rules based upon where the developer happens to drop a widget.
Recomputing size and position
Changing the details of a widget often cause
the sizes to have to be recomputed. For example nne change in
cause that whole hierarchy to go through re-size/re-position work. If you have container inside container which is inside another container etc., means that parents re-size/re-position their children and that can be very
expensive for deep hierarchies.
Does the ConstraintLayout have better performance then a nested
ConstraintLayout is being designed with performance in mind, trying to eliminate
as many pass scenarios as possible and by trying to eliminate the need for
deeply-nested view hierarchies.
for more you can take a look in a book about android development from CommonsWare.
ConstraintLayout is explained in more details with comparation examples with another containers like
RelativeLayout etc. Really anatomy of android development.