There is a HomeFragment and in the "onCreateView", I want to change the "layout_constraintTop_toBottomOf" of a view, Is it possible?
<VideoView
android:id="@+id/videoViewMain"
...
app:layout_constraintTop_toBottomOf="parent" />
<androidx.appcompat.widget.AppCompatToggleButton
android:id="@+id/appCompatToggleButton"
...
app:layout_constraintTop_toBottomOf="@+id/imageViewMain" />
Change
app:layout_constraintTop_toBottomOf="@+id/imageViewMain"
to:
app:layout_constraintTop_toBottomOf="@+id/videoViewMain"
Tried code but doesn't work:
ConstraintLayout constraintLayout = (ConstraintLayout)root.findViewById(R.id.imageViewMain);
AppCompatToggleButton appCompatToggleButton= root.findViewById(R.id.appCompatToggleButton);
constraintLayout.addView(appCompatToggleButton);
ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(constraintLayout);
constraintSet.connect(appCompatToggleButton.getId(), ConstraintSet.BOTTOM,
constraintLayout.getId(), ConstraintSet.BOTTOM, 0);
constraintSet.applyTo(constraintLayout);