I am using the following layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="start"
app:constraint_referenced_ids="right_txt1,right_txt2,right_txt3"/>
<TextView
android:id="@+id/right_txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bar"
android:gravity="end"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/left_txt1"
app:layout_constraintBottom_toBottomOf="@id/left_txt1"
/>
<TextView
android:id="@+id/right_txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bar Bar"
android:gravity="end"
app:layout_constraintTop_toBottomOf="@id/c1"
app:layout_constraintEnd_toEndOf="parent"
/>
<TextView
android:id="@+id/right_txt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bar"
app:layout_constraintTop_toBottomOf="@id/c2"
app:layout_constraintEnd_toEndOf="parent"
/>
<View
android:id="@+id/view1"
android:layout_width="120dp"
android:layout_height="10dp"
android:background="@color/green"
app:layout_constraintTop_toTopOf="@id/right_txt1"
app:layout_constraintBottom_toBottomOf="@id/right_txt1"
app:layout_constraintEnd_toStartOf="@id/barrier"
/>
<View
android:id="@+id/view2"
android:layout_width="120dp"
android:layout_height="10dp"
android:background="@color/green"
app:layout_constraintTop_toTopOf="@id/right_txt2"
app:layout_constraintBottom_toBottomOf="@id/right_txt2"
app:layout_constraintEnd_toStartOf="@id/barrier"
/>
<View
android:id="@+id/view3"
android:layout_width="120dp"
android:layout_height="10dp"
android:background="@color/green"
app:layout_constraintTop_toTopOf="@id/right_txt3"
app:layout_constraintBottom_toBottomOf="@id/right_txt3"
app:layout_constraintEnd_toStartOf="@id/barrier"
/>
<TextView
android:id="@+id/left_txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start"
app:layout_constrainedWidth="true"
app:layout_constraintTop_toTopOf="@id/view1"
app:layout_constraintBottom_toBottomOf="@id/view1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/view1"
app:layout_constraintHorizontal_bias="0"
android:text="FooBar"
/>
<androidx.constraintlayout.widget.Constraints
android:id="@+id/c1"
android:layout_width="match_parent"
android:layout_height="1dp"
app:layout_constraintTop_toBottomOf="@id/left_txt1"
app:layout_constraintStart_toStartOf="parent"
/>
<TextView
android:id="@+id/left_txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintTop_toTopOf="@id/view2"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/c1"
app:layout_constraintBottom_toBottomOf="@id/view2"
app:layout_constraintEnd_toStartOf="@id/view2"
android:text="FooBarBaz"
/>
<androidx.constraintlayout.widget.Constraints
android:id="@+id/c2"
android:layout_width="match_parent"
android:layout_height="1dp"
app:layout_constraintTop_toBottomOf="@id/left_txt2"
app:layout_constraintStart_toStartOf="parent"
/>
<TextView
android:id="@+id/left_txt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@id/view3"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/left_txt2"
app:layout_constraintBottom_toBottomOf="@id/view3"
app:layout_constraintEnd_toStartOf="@id/view3"
android:text="FooBar"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
This is ok for this example but what I want is that as the text grows the individual items adjust as a group without losing alignment. Examples that don't work properly:
and margins don't work
E.g. adding android:layout_marginBottom="18dp"
to the left_txt1
has no effect or adding android:layout_marginBottom="18dp"
to the
left_txt2` has the following effect
I would like as the text grows the items bellow/above give space as a group
What am I messing up here?