Answer the question
In order to leave comments, you need to log in
How to resize a ConstraintLayout while the application is running?
I need to remove (height = 0) the child ConstraintLayout under a certain condition, and then show it again (height = match_constraint). Tried this:
Remove:
val c = ConstraintSet()
c.clone(constraintLayoutTable)
c.constrainMaxHeight(R.id.constraintLayoutTableTitle, 0)
c.constrainPercentHeight(R.id.constraintLayoutTableTitle, 0.0f)
c.applyTo(constraintLayoutTable)
val c = ConstraintSet()
c.clone(constraintLayoutTable)
c.constrainHeight(R.id.constraintLayoutTableTitle, ConstraintSet.MATCH_CONSTRAINT)
c.constrainMaxHeight(R.id.constraintLayoutTableTitle, 100)
c.constrainPercentHeight(R.id.constraintLayoutTableTitle, 100.0f)
c.applyTo(constraintLayoutTable)
<android.support.constraint.ConstraintLayout
android:id="@+id/constraintLayoutTableTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="8dp"
android:text="I"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="I" />
<TextView
android:id="@+id/textView14"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Test"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/textView13"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question