缺少约束布局 alpha7 ConstraintCenterX/Y 属性

Constraint-Layout alpha7 ConstraintCenterX/Y attribute missing

我刚刚从 com.android.support.constraint:constraint-layout:1.0.0-alpha5 更新到 com.android.support.constraint:constraint-layout:1.0.0-alpha7,但是缺少 layout_constraintCenterX_toCenterXlayout_constraintCenterY_toCenterY。他们是否更改了他们的名字,或者是否有将两个视图居中的替代方案。

编辑 - 我确实在这里看到了他们的发行说明 http://tools.android.com/recent/constraintlayout-alpha7available 他们只是说它已被弃用。但我想要一个解决方案(替代方案)。

是的,在 ConstraintLayout-alpha 7 的发行说明中 here

如果你想让 B 的中心与 A 的中心对齐,那么你应该让 B 的左右与 A 的左右对齐。

这是一个例子 - text2 将位于 text1 的下方和中心:

<TextView
    android:id="@+id/text1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:labelFor="@+id/text2"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent" />

<TextView
    android:id="@+id/text2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintLeft_toLeftOf="@+id/text1"
    app:layout_constraintRight_toRightOf="@+id/text1"
    app:layout_constraintTop_toBottomOf="@+id/text1" />

支持 RTL 的简单解决方案

app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias=".5"

不支持 RTL

app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias=".5"

如果需要,您可以删除 app:layout_constraintHorizontal_bias

我也在这里报告了 RTL 错误:

Link 1

Link 2