Как использовать ConstraintLayout Barrier для позиционирования вида справа от других видов? - PullRequest
2 голосов
/ 13 марта 2019
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <TextView
            android:id="@+id/text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            tools:text="One"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent"/>
    <TextView
            android:id="@+id/text2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            tools:text="Two Two"
            app:layout_constraintTop_toBottomOf="@id/text1"
            app:layout_constraintStart_toStartOf="parent"/>

    <android.support.constraint.Barrier
        android:id="@+id/barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="end"
        app:constraint_referenced_ids="text1,text2"/>

    <TextView
            android:id="@+id/text3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toEndOf="@id/barrier"
            tools:text="Three"/>

</android.support.constraint.ConstraintLayout>

Я пытаюсь поместить text3 справа от text1 и text2, используя ConstraintLayout Barrier , но приведенный выше текст text3 помещается поверх text1 и text2.Что не так с приведенным выше макетом?Как я могу использовать барьер ConstraintLayout, чтобы поместить text3 справа от text1 и text2?enter image description here

...