Recent Changes‎ > ‎

ConstraintLayout alpha 9 is now available

posted Sep 28, 2016, 8:33 PM by Nicolas Roard   [ updated Sep 29, 2016, 6:22 AM ]
We are very excited to announce the release of ConstraintLayout alpha 9 -- this contains the final feature set for 1.0, and is the final step before releasing the first beta candidate release.
It's available in the SDK Manager (under the "Support Repository" section).

Note: As for alpha 8, if you are using Android Studio 2.2 and it is your first installation of ConstraintLayout, you might have to restart studio (or invalidate caches) after installing alpha 9 (the editor behavior may not be correct, with widgets temporarily snapping to the top left corner). 

We fixed a few issues in this build:
  • we had a regression in the way we handled text wrap
  • correct handling of RTL for horizontal bias
  • correct handling of GONE for constraint ratios
We added some new features and some performance improvements
  • loading constraints directly from XML files with ConstraintSet
  • support for Chains in the layout and in ConstraintSet
A few words about Chains

Chains are a very powerful new feature that allow you to set up certain group behavior that would otherwise be difficult or impossible to do in ConstraintLayout. They work in a single axis (you can have a vertical chain without having the elements of the chain be affected horizontally), and maintain a flat hierarchy. 
  • Widgets are considered part of a chain if they are connected to other widgets with bi-directional constraints, e.g. in A<-B<->C->D, B and C are part of a chain
  • Chains allow you to control how the elements of a chain will be positioned over the available space; e.g. |AB---|, |---AB|, |--AB--|, |-A-B-|, or stretched |AAAB|
  • A chain can be either packed (layout_constraintHorizontal_chainPacked and layout_constraintVertical_chainPacked attributes of the first widget in the chain), in that case the chain position will be controlled via the layout_constraintHorizontal_bias and layout_constraintVertical_bias attributes (still on the first widget in the chain).
  • Or spread. In that case the widgets of the chain will be positioned equally in the available space. If one or more widget is set to MATCH_CONSTRAINT, they will divide the available space equally and be resized to use it. How much each widget set to MATCH_CONSTRAINT will use the available space can be controlled by the attributes layout_constraintHorizontal_weight and layout_constraintVertical_weight

Note that while chains allow you to keep a flat hierarchy (e.g. no need to use an embedded sub layout), it is perfectly fine to continue using sub layouts (e.g. a linear layout inside a constraint layout), particularly if they help while building your UI conceptually. The idea with chains though is that it allows you to use sub layouts only when it makes sense.

Important: The layout editor in AndroidStudio 2.2 does not support the new Chains feature, so will not have affordances to help you create chains. The preview visualisation ("design mode") in the layout editor will show you the correct positioning if you use chains, but the blueprint mode will not, showing incorrect bounds for the widgets. We are planning to update the editor in our next Android Studio preview release, to support Chains adequately.

Please give us feedback on this release, as this should be our last alpha :)
Comments