ConstraintLayout 中的居中对齐行为

Center align behavior in ConstraintLayout

我有一张宽度和高度相同的图像,它是设备宽度的 60%。我希望图像的垂直中心为设备高度的 45%。我的代码如下:

我已经将constraintTop 和constraintBottom 设置为准则,但它就像constraintBottom 不起作用一样。该图像位于指南的底部。我不知道我的代码有什么问题。

我试过把'android.support.constraint.ConstraintLayout'换成'androidx.constraintlayout.widget.ConstraintLayout',结果还是不理想:

我用蓝色填充图像来说明问题和我手机上的结果:

这发生在 ConstraintLayout 的 1.1.3 版本中,并且在某种程度上与 0dp 的尺寸和 app:layout_constraintDimensionRatio="1:1" 的设置有关。这不会发生在版本 2.0.4 中,因此如果可以,请升级到该版本。