0
<TextView
    android:id="@+id/tvTitle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Get Ready For"
    android:textSize="22sp"
    android:textColor="@color/colorAccent"
    android:textStyle="bold"
    android:textAllCaps="false"
    app:layout_constraintTop_toBottomOf="@id/toolbarExercise"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintBottom_toTopOf="@id/readyflProgressBar"
    />

I want to change the constraints of this TextView programatically through kotlin. How do I do that?

Mark31
  • 11

1 Answers1

0

This Works For Me

In My Xml :

 app:layout_constraintRight_toRightOf="@+id/view1"
 app:layout_constraintTop_toTopOf="@+id/view2" 

java

ConstraintLayout constraintLayout = findViewById(R.id.parent_layout);
     ConstraintSet constraintSet = new ConstraintSet();
     constraintSet.clone(constraintLayout);
     constraintSet.connect(R.id.otherView,ConstraintSet.RIGHT,R.id.view1,ConstraintSet.RIGHT,0);
     constraintSet.connect(R.id.otherView,ConstraintSet.TOP,R.id.view1,ConstraintSet.TOP,0);
     constraintSet.applyTo(constraintLayout);