Android: ConstraintLayout - 如何创建具有相同权重的链

Android: ConstraintLayout - How to create a chain with equal weights

我有两个视图必须水平并排放置,并且它们需要占据 space 的 50%。 这可以通过指南轻松完成。

但问题是每个视图都必须能够移动以获取另一个视图的 space,以防另一个视图消失。 这通过指南是不可能的,但在使用链条时是可能的。

但是链条的问题是我无法确保两者(当两者都可见时)占据分配给它们的总宽度水平区域的 50%。

有人可以看看下面的代码有什么问题吗:

<?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:background="@color/dark_background"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:padding="15dp"
    tools:layout_width="500dp"
    tools:layout_height="300dp"
    >



    <!--<android.support.constraint.Guideline-->
        <!--android:id="@+id/guideline"-->
        <!--android:layout_width="0dp"-->
        <!--android:layout_height="0dp"-->
        <!--android:orientation="vertical"-->
        <!--app:layout_constraintLeft_toRightOf="@id/title"-->
        <!--app:layout_constraintRight_toRightOf="@id/title"-->
        <!--app:layout_constraintGuide_percent="0.5"-->
        <!--/>-->

    <TextView
        android:id="@+id/title"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/image"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@+id/ic_share"
        android:ellipsize="marquee"
        android:maxLines="4"
        android:textSize="20sp"
        android:textColor="#000000"
        android:text="This is a test content title. This would be changed eventually"
        />

    <ImageView
        android:id="@+id/image"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:adjustViewBounds="true"
        android:src="@drawable/ic_logo"
        app:layout_constraintDimensionRatio="4:3"
        app:layout_constraintLeft_toRightOf="@+id/title"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintVertical_bias="0.0"

        />

</android.support.constraint.ConstraintLayout>

是的,我认为这是一个错误。我在这里提交:

https://code.google.com/p/android/issues/detail?id=248117