On the newest version of constraint layout, Beta 5, using match_parent throws an exception:
android.view.InflateException: Binary XML file line #12: MATCH_PARENT is not supported in ConstraintLayout
As explained in the release note:
"(...) its behavior undefined. To reduce the risk of errors we now throws an exception if we encounter it." - source
They suggested that the correct usage would be to use 0dp (MATCH_CONSTRAINT), but since I have a Drawer Layout inside my constraint layout, setting the width to 0dp throws "DrawerLayout must be measured with MeasureSpec.EXACTLY" error.
So my question is how can I suppress the error "MATCH_PARENT is not supported in ConstraintLayout"?
The replacement of
android:layout_width="match_parent"
in a ConstraintLayout can be done with
android:layout_width="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
i.e. constraining the widget to the right and left edges of the parent
At least as of version 1.1.0-beta3 of the constraint layout,
You can use match_parent without issues.
However it's still recommended that you use:
android:layout_width="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With