5

For example, if i want to position button B to the right of button A.

enter image description here

Relative Positioning Constraints:

enter image description here

I can to use:

1)<Button android:id="@+id/buttonB" ... app:layout_constraintLeft_toRightOf="@+id/buttonA" />

Or

2)<Button android:id="@+id/buttonB" ... app:layout_constraintStart_toRightOf="@+id/buttonA" />

What is difference between example 1 and 2?

References: https://developer.android.com/reference/android/support/constraint/ConstraintLayout

2 Answers2

2

There is no as such difference in both . As you can see in you image , they have mentioned above left as start and right as end .

start and end was introduced in API level 17 What is the difference between Android margin start/end and right/left?

Even if you try to use

<Button android:id="@+id/buttonB" ...
             app:layout_constraintStart_toEndOf="@+id/buttonA" />

will result the same as

<Button android:id="@+id/buttonB" ...
             app:layout_constraintLeft_toRightOf="@+id/buttonA" />

But i didn't find this constraint till now ... mixture of both start and right. Even this didn't appeared in xml .

app:layout_constraintStart_toRightOf
Mini Chip
  • 949
  • 10
  • 12
1

Right/left versus start/end

"Right" and "left" always refer to the right and left sides of the screen, whether your app uses a left-to-right (LTR) flow or a right-to-left (RTL) flow. "Start" and "end" always refer to the start and end of the flow:

For a LTR flow, start = left and end=right. For a RTL flow, start=right and end=left. If your app targets API level 17 (Android 4.2) or higher:

Use "start" and "end" instead of "left" and "right". For example, android:layout_marginLeft should become android:layout_marginStart to support RTL languages. If you want your app to work with versions lower than Android 4.2; that is, if the app's targetSdkVersion or minSdkVersion is 16 or lower:

Add "start" and end" in addition to "left" and "right". For example, use both android:paddingLeft and android:paddingStart.

Source: kotlin-android-training by Google

Johny Gates
  • 75
  • 1
  • 9