7

Can anyone please explain what app:layout_constraintHorizontal_bias is used for?

Ola Ström
  • 4,136
  • 5
  • 22
  • 41
ayushkadbe
  • 91
  • 2
  • 13
  • https://developer.android.com/training/constraint-layout#adjust-the-constraint-bias look at this, easy to understand – Công Hải Jun 01 '20 at 03:55

2 Answers2

12

Position View - bias

bias: (constraint area size - view size) distribution ratio.

app:layout_constraintHorizontal_bias="0~1"

0: Attach to the left

1: Attach to the right

0.5: Center (default)

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="button1"
    app:layout_constraintHorizontal_bias="0"
    ... />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="button2"
    app:layout_constraintHorizontal_bias="1"
    ... />

enter image description here

Nadeem Iqbal
  • 2,357
  • 1
  • 28
  • 43
S T
  • 1,068
  • 2
  • 8
  • 16
0

The default when encountering such opposite constraints is to center the widget; but you can tweak the positioning to favor one side over another using the bias attributes:

layout_constraintHorizontal_bias layout_constraintVertical_bias

Basically for this type of questions you should check Official Documentation instead of posting here... here is link to official documnetation for Bias.... Learn More About Bias

gagangamer
  • 14
  • 1
  • 6