I want to programmatically set Width as WRAP_CONTENT to constraint layout.
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@ id/asdA"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
I am not able to do so, I've searched in stack but just able to do it. Using Kotlin!
CodePudding user response:
Option 1
asdA.layoutParams = ViewGroup.LayoutParams(ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
Option 2:
val params = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_PARENT,
ConstraintLayout.LayoutParams.WRAP_CONTENT)
.asdA?.setLayoutParams(params)