官术网_书友最值得收藏!

Controlling position with bias

Bias can be best understood here as a percentage value, but rather than position the view according to its center or a corner, it is the percentage of space either side of it. So if the bias towards the top is 33%, then the margin below will be twice the size of the one below it.

Setting bias is even easier than understanding it, as once a constraint is set on any opposing sides of a view, an associated slider will appear in the Properties graphic Properties editor:

Applying bias with the GUI

A quick glance at the generated code shows the format for this attribute as follows:

app:layout_constraintHorizontal_bias="0.33" 

The value of using bias to position screen elements lies partly in the simplistic approach, but its true value comes when it comes to developing for multiple screens. There are so many models available and they all seem to have slightly different proportions. This can make design layouts that look fantastic on all of them, very time consuming and even shapes as similar as 720 x 1280 and 768 x 1280 can produce undesirable results when tested with the same layout. The use of the bias attribute goes a long way to solving these issues, and we shall see more of this later when we take a look at layout previews and the percent library.

The Design and Text modes of the editor can be switched between using Alt + Left or Right.

As if all this didn't make designing a layout easy enough, constraint layouts have two other extremely handy functions that almost automate UI design: auto-connect and inference.

主站蜘蛛池模板: 华容县| 尚志市| 哈尔滨市| 芦山县| 株洲市| 池州市| 滨海县| 清苑县| 四子王旗| 乌什县| 壤塘县| 睢宁县| 临夏市| 常山县| 吕梁市| 莱西市| 巴中市| 横峰县| 甘泉县| 沂南县| 孝昌县| 廊坊市| 尚志市| 奈曼旗| 南昌市| 榆中县| 三河市| 碌曲县| 霍州市| 惠州市| 农安县| 武陟县| 孟州市| 雷州市| 永兴县| 南木林县| 潞城市| 河北省| 尼木县| 新和县| 贵定县|