constraintlayout
constraintlayout copied to clipboard
Suspected bug in optimizer
I simplified the bug to this layout and observed. This is related to some other reported issues.
https://github.com/androidx/constraintlayout/issues/397 https://github.com/androidx/constraintlayout/issues/411 https://github.com/androidx/constraintlayout/issues/421
- Removing this in the TextView
app:layout_constraintWidth_default="wrap"
can remove the bug. - Also, setting
app:layout_optimizationLevel="none"
would also eliminate the issue.
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tool="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#cff"
tool:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<TextView
android:id="@+id/b"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginRight="280dp"
android:background="#8f0f"
android:text="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdef"
app:layout_constraintWidth_default="wrap"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="b"/>
<View
android:layout_width="0dp"
android:layout_height="10dp"
android:background="#8fe6"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/barrier"/>
</androidx.constraintlayout.widget.ConstraintLayout>```
Hi All, I also recently updated to 2.1 and my app UI is also broken.
I am creating customview inheriting from constraint layout.
vertical view is not getting rendered properly.
few libraries have updated to 2.1 and we have dependency moving to latest constraint layout due to this.
Kindly let me know if this bug is fixed in the latest release?
@camaelon @jswong65 can we know when will this defect be fixed.
This will not be fixed in this release cycle. It will probably be addressed mid year next year.
I suggest setting app:layout_optimizationLevel="none" Internally the fix will be to detect the situation and turn off the optimizer.
app:layout_optimizationLevel="none"
works here!