Home > Net >  What is 'Vertical Bias' or 'Horizontal Bias' used for in Android's 'Co
What is 'Vertical Bias' or 'Horizontal Bias' used for in Android's 'Co

Time:10-18

I am quite new to Android development and today I wondered what the 'Vertical Bias' respectively the 'Horizontal Bias' is used for in the 'ConstraintLayout'.

CodePudding user response:

In short - it tells the layout how to place a view between the constrained views. If Your view inside ConstraintLayout has these:

app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"

it will be placed in the middle by default.

But You can add:

app:layout_constraintHorizontal_bias="1" to place it at the end of the constraint (parent in this example)
app:layout_constraintHorizontal_bias="0" to place it at the beginning of the constraint (parent in this example)
app:layout_constraintHorizontal_bias="0.33" to place it on/third of the space from the begining of the constraint (parent in this example)

etc.

Vertical bias does the same vertically.

  • Related