Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is 'Vertical Bias' or 'Horizontal Bias' used for in Android's 'ConstraintLayout'?

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

like image 373
Chris Avatar asked Sep 07 '25 02:09

Chris


1 Answers

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.

like image 80
Miłosz Avatar answered Sep 10 '25 11:09

Miłosz