I have a working layout in .xml file no problem here. In my code there is a button that show or hide these two imageViews. When I hide the two imageViews I want to set the checkbox layout constraints to mach parent instead of matching constraints("0dp"), and when I show the the two imageViews I want to set checkbox layout to match constraints.
<?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:id="@+id/constraint_child"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/delete_child"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginStart="16dp"
android:src="@drawable/delete"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/edit_child"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="@+id/checkbox_child"
android:layout_width="0dp"
android:layout_height="42dp"
android:text="CheckBox"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/edit_child"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/edit_child"
android:layout_width="26dp"
android:layout_height="26dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/delete_child"
app:layout_constraintStart_toEndOf="@+id/checkbox_child"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/edit" />
</androidx.constraintlayout.widget.ConstraintLayout>
I don't want to create the CheckBox and the two ImageViews programmatically ,because I have created them before in .xml file. what I want is changing these views programmatically in java. Thanks in advance.