How to suppress constraint layout error "MATCH_PARENT is not supported in ConstraintLayout"

In the latest version of the constraint layout, Beta 5 throws an exception using match_parent:

android.view.InflateException: Binary XML file line #12: MATCH_PARENT is not supported in ConstraintLayout 

As explained in the release note:

"(...) his behavior is undefined. To reduce the risk of errors, we now throw an exception if we encounter this." - source

They suggested that the correct use 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 error must be measured with MeasureSpec.EXACTLY error".

So my question is, how can I suppress the error "MATCH_PARENT is not supported in ConstraintLayout"?

+6
source share
2 answers

At least since version 1.1.0-beta3 of the layout constraint,

You can use match_parent without any problems.

However, he still recommends using:

 android:layout_width="0dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" 
+1
source

Replacement

 android:layout_width="match_parent" 

in ConstraintLayout can be done with

 android:layout_width="0dp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" 

i.e. widget restriction on the right and left edges of the parent

+12
source

Source: https://habr.com/ru/post/1014889/


All Articles