ConstraintLayout中设置match_parent后约束失效

ConstraintLayout中设置match_parent后约束失效

设置viewpager在View底部之后再设置宽高match_parent后按照之前外面用RelativeLayout或LinearLayout布局包裹的话Viewpager应该填充View下面的全部屏幕才对,但是外面用ConstraintLayout却出现了约束失效Viewpager充满整个屏幕的情况,经查询官方文档发现被ConstraintLayout 包裹的控件不支持 match_parent 的取值,但实际在AS中使用的时候,并没有match_constraint ,所以实际使用时 使用0dp 表示 match_constraint 即可。
原文Widgets dimension constraints描述如下:Important: MATCH_PARENT is not supported for widgets contained in a ConstraintLayout, though similar behavior can be defined by using MATCH_CONSTRAINT with the corresponding left/right or top/bottom constraints being set to "parent".