O'Reilly logo

Mastering Android Studio 3 by Kyle Mew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required