To get a packed column is more difficult because the chain icon only controls the first chain that a component is in. At the time of writing the only way to set packed on the columns is to edit the XML file.
The chain style is controlled by the first component in the chain. If you look at the XML for the first button in the first row you will see:
If you change the top row button’s XML correctly you should see a packed array of buttons:
The big problem now is that to position the grid of Buttons you have to adjust the bias settings of the first button in each row, which sets the horizontal bias for that row, and the settings of the first button in each column, which sets the vertical bias. There is no single setting that will position the entire grid, and this doesn’t make positioning easy.
What about adding the tenth Button?
It could have been added to the first column but it is just as easy to add it now and set a constraint from the bottom of the last Button in the first column and from the right and left side of the button:
Summary of Chapter
Italics indicate material in chapter but not in article.
The ConstraintLayout is the layout of the future and the new Layout Editor was created to work best with it.
There are two automatic constraint tools – Autoconnect which works out constraints for a single component, and Infer Constraints which works out any missing constraints for the entire layout. Neither tool is currently particularly useful.
You can clear all of the constraints in a layout, or just those on a single component or a constraint at a time.
Constraints can be applied from a component to the parent container and these act like absolute positioning.
You can set default margins to make positioning components more regular.
Components can be positioned relative to another component.
You cannot set negative margins.
You can align text baselines.
Bias constraints allow you to set positions that divide the space available in a specified proportion.
Chains provide some of the features of a LinearLayout. For example, you can use a chain to distribute components across the available space.
Guidelines can be added to a layout and components can be positioned relative to them, even though they don’t appear in the final layout.
Groups can be created which allow you to set the visibility of all of the components in one go.
You can set the size of a component absolutely or to be determined by the content. In addition, you can allow a pair of constraints to determine the size.
An Aspect Ratio Constraint can set one dimension as the ratio of another.
A Barrier is a smart guideline that tracks a specified group of components and is positioned at the most extreme edge of the group in a specified direction. You can position other components relative to the Barrier.