UI Layouts - Constraints v/s Relative


#1

I have been through a few books on Android Programming and the official site of Google for Android Devlopers, it appears the development is moving towards using Constraint Layout completely. Even the Android Studio Version 3.0.1 uses Constraint Layout as default.
Why then we still find books and stuffs starting UI introduction with Relative Layouts and not Constraint Layouts. Is it so because modifying XMLs still gives us Java hangover or it is difficult to explain Constraint Layout initially which is so much dependent on views and looks (nothing is meant to be modified in XML).

This was initially a problem for me where I started with Relative Layouts and then found every explanation is trying to use Constraint Layouts now.

Any views on this?

Thanks
Arnab


#2

In our books, we always recommend what we actually use day to day in our consulting work that we do. Over time, ConstraintLayout has replaced our RelativeLayout usage completely. We no longer use RelativeLayout.

That said, we never used RelativeLayout that often and still to this day, we don’t use ConstraintLayout that often. At most, I would say 1 out of every 20 layout files we build use ConstraintLayout. I think ConstraintLayout will continue to gain traction and be used more and more often in the future. Early on, there were many bugs in the tools around ConstraintLayout (that may still be the case as new features are added).

We find XML layouts to generally be easier to understand and read than ConstraintLayouts and XML layouts are definitely easier to review by someone else in code review. At the end of the day, our layout files end up not being too complex and ConstraintLayout is really overkill for that.

I do think we’ll see ConstraintLayout usage grow in the future, but that’s where it is now for us.


#3

True. The very crucial fact is that review of a layout written in Relative Layout is easier to understand. So in terms of portability and for others to understand what the UI is all about Relative Layout is way ahead.
But in terms of pure designing the Constraint Layout is not that bad. It gives the developer a true designer kind of feeling :slight_smile:

Thanks for your views. I still keep changing from one style to the other as and when I feel comfortable and that should be the general approach as well.

Thanks
Arnab