将match_parent转换为“ 0dp”

Rah*_*rma 0 android android-layout android-studio android-constraintlayout

当我在“约束布局”中将android:layout_height="match_parent"android:layout_width="match_parent"用作子项的高度/宽度并构建Gradle文件时,它将自动更改为android:layout_height="0dp"android:layout_widtht="0dp"

从技术上讲,0dpmatch_parent之间存在巨大差异。

在大多数情况下,它不会影响我的布局,但有时这东西会完全破坏我的约束布局。

我不知道为什么会这样。
请指导我。

Nic*_*ard 5

ConstraintLayout不支持match_parent。如果您想要相同的行为,请使用0dp并在父级的每一侧设置约束。

  • 如果不支持match_parent,为什么要在IDE的layout_width和layout_height下拉列表中将其设为选项?我并不是说您错了(因为显然,如果您在Google工作,并且您的名字不断出现,并回答ConstraintLayout问题,那么您显然知道很多)。但是我说的是ConstraintLayout的整个当前实现都是一团糟,目前无法使用。 (3认同)