What’s New in Android: ConstraintLayout — Google I/O 2016

Elif Boncuk
4 min readJun 3, 2016

--

As starting with ConstraintLayout, I will try to explain what’s in new in Android at these series.

First of all, I took all the screenshots below from Android Studio 2.2 Preview, so if you want to try the samples, I strongly recommend you to download.

As I see from this year’s new features, Google makes writing code in Android extremely easier. Most of the things that we have to do, think to do are started to do by the system itself. Actually, this really makes coding so simple that if there is anyone who wants to learn coding, that is the time.

Yes, the most exciting feature in the concept of layout is ConstraintLayout. If you also develop IOS applications, constraint is a very well down feature. On the other hand, Android makes the move and adds percentages in addition to IOS constraint features. Actually, I was thinking about that the only missing thing for Relative Layout is percentage. As same with Relative Layout, we build a layout structure that is not nested. But sometimes we still need to use inner layouts at RelativeLayout. ConstraintLayouts has over this completely.

ConstraintLayout is unbundled. It means you can use it without updating the framework. In addition, it is compatible since Ginderbread(Android 2.3). It covers the 99.9 percent of the devices.

ConstraintLayout is the first layout that is used by tool. (LayoutManager) This provided LayoutManager built and this user experience designed for Android Studio.

We can add whatever layout we want with dragging the components from palette which is lying on the left side of the Layout Manager. When we first add a layout inside a ConstraintLayout, Layout Manager offers the margins according to Material Guideline. This provides us not to make mistake about design.

For example, we see two buttons side by side. We add constraits to these views between each other. As I mentioned earlier, if you write code in IOS,too, this feature would be ordinary to you.

The real powerful feature of this editor is when we move the layouts on editor, Android Studio runs a layout algorithm at 60 fps so we can see what’s happening in real and how the layout resolves the constraints. So this can give early feedback to us.

The button which is lying upper side of the screen and looking like magnet is autoconnect button. While autoconnect is open, if we add a button to the screen, the constraints could be added according the location on the screen. Of course, we can change the constraints after. We can change the percentage, also. We can do this both at layout and also at properties tab sliding the percentage bar.

While using the X button below, we can remove all the constraints at ones and also can add auto constraints as using bubble button.

If we a little mention about visibility, lets think that we have three view having constraints between each other. And let change the visibility of in the middle. If we make it invisible, nothing has changed. Because, actually view is in there, just you can’t see it. But, what happens if we make it gone? The view which is done gone can’t be seen but constraints are still there. So we do not have to do any additional development for it. At IOS, we can do this by using UIStackView.

The whole features coming with ConstraintLayout and Layout Manager are design to create UI faster and all of it could be used at Android Studio 2.2 Preview. Romain Guy finished it talk as saying his following the bugs personally and the team trying to solve as many bugs as possible. They want us to use it and give feedback to them.

I hop it would be helpful. I will move on with other improvements in Android.

References:

--

--

Elif Boncuk

Engineering Manager, Digital Banking @GarantiBBVA | #Android #GDE | formerly volunteer @MobilerDev @gdgIstanbul @wtmist | #CE @Hacettepe1967 #MBA @Bahcesehir