2016-09-13 1 views
1

Я только что обновил до com.android.support.constraint:constraint-layout:1.0.0-alpha7 от com.android.support.constraint:constraint-layout:1.0.0-alpha5, но layout_constraintCenterX_toCenterX и layout_constraintCenterY_toCenterY отсутствуют. они изменили свои имена или если есть альтернатива, чтобы центрировать два взгляда.Недостаток атрибута alpha7 ConstraintCenterX/Y отсутствует

EDIT - Я видел их примечание к выпуску http://tools.android.com/recent/constraintlayout-alpha7available, они просто сказали, что это устарело. но я хочу решение (альтернативное).

ответ

0

Да, его в релиз нотой ConstraintLayout-альфа 7 here

enter image description here

2

Если вы хотите совместить центр B с центром а, в чем вы должны иметь B выровнять это левый и правый с А-х Лево и право.

Вот пример - 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" /> 
+0

Что говорит Джо. Обратите внимание, что centerX_toCenterX был в основном просто ярлыком - внутри он делал left_toLeftOf и right_toRightOf. То же самое fo centerY. –

0

простое решение с поддержкой 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" 

вы можете удалить приложение: layou t_constraintHorizontal_bias если вы хотите

я также сообщил RTL ошибка здесь:

Link 1

Link 2