ConstraintLayout 左对齐两个水平链的中间元素?

ConstraintLayout left align the middle element of two horizontal chains?

我正在创建一个布局,其中我需要创建 2 行,每行三个元素。对于两行的中间元素(Qty4901),我希望文本左对齐。

我创建了 2 个水平链,chainStylespread_inside

布局如下xml:

https://gist.github.com/asheshb/cb2effdbb92e34d897672eb730339896

知道怎么做吗?

尽管我不推荐这种方法,但请尝试下面的布局,因为如果您在 TextView 中插入一个太长的值(例如 Curr.Value),则只有附加的元素(在本例中为 TextView包含此数字 15,13,​​184) 将适应这些更改,并且布局将被破坏。

<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:id="@+id/nse_item_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp">

<TextView
    android:id="@+id/tvStockName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="18sp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    tools:text="ICICI BANK LIMITED" />

<TextView
    android:id="@+id/tvStockSymbol"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="12sp"
    app:layout_constraintStart_toStartOf="@+id/tvStockName"
    app:layout_constraintTop_toBottomOf="@+id/tvStockName"
    tools:text="ICICIBANK" />

<TextView
    android:id="@+id/tvStockValue"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="end"
    android:textSize="24sp"
    android:textStyle="bold"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    tools:text="306.75" />

<TextView
    android:id="@+id/tvStockPercent"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="2dp"
    android:textSize="12sp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvStockValue"
    tools:text="(1.44%)"
    />


<TextView
    android:id="@+id/tvStockDifference"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="4dp"
    android:textSize="16sp"
    app:layout_constraintEnd_toStartOf="@+id/tvStockPercent"
    app:layout_constraintTop_toBottomOf="@+id/tvStockValue"
    tools:text="-4.50"
    />

<TextView
    android:id="@+id/tvAvgPriceTitle"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:textSize="16sp"
    tools:text="Avg. Price"
    app:layout_constraintHorizontal_weight="50"
    app:layout_constraintEnd_toStartOf="@+id/tvQtyTitle"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintHorizontal_chainStyle="spread_inside"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvStockDifference" />

<TextView
    android:id="@+id/tvQtyTitle"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:textSize="16sp"
    tools:text="Qty"
    app:layout_constraintHorizontal_weight="10"
    app:layout_constraintEnd_toStartOf="@+id/tvCurrentValueTitle"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toEndOf="@+id/tvAvgPriceTitle"
    app:layout_constraintTop_toBottomOf="@+id/tvStockDifference" />

<TextView
    android:id="@+id/tvCurrentValueTitle"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    tools:text="Curr. Value"
    android:textSize="16sp"
    app:layout_constraintHorizontal_weight="20"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toEndOf="@+id/tvQtyTitle"
    app:layout_constraintTop_toBottomOf="@+id/tvStockDifference" />


<TextView
    android:id="@+id/tvAvgPrice"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:textSize="16sp"
    app:layout_constraintHorizontal_weight="50"
    app:layout_constraintEnd_toStartOf="@+id/tvQty"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintHorizontal_chainStyle="spread_inside"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvAvgPriceTitle"
    tools:text="241.83" />

<TextView
    android:id="@+id/tvQty"
    android:layout_width="0dp"
    android:layout_height="20dp"
    app:layout_constraintHorizontal_weight="10"
    app:layout_constraintEnd_toStartOf="@+id/tvTotalStockInvestment"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintStart_toEndOf="@+id/tvAvgPrice"
    app:layout_constraintTop_toBottomOf="@+id/tvQtyTitle"
    tools:text="4901" />

<TextView
    android:id="@+id/tvTotalStockInvestment"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:textSize="16sp"
    app:layout_constraintHorizontal_weight="20"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toEndOf="@+id/tvQty"
    app:layout_constraintTop_toBottomOf="@+id/tvCurrentValueTitle"
    tools:text="15,13,184" />


<TextView
    android:id="@+id/tvTotalStockPercent"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:textSize="12sp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvTotalStockInvestment"
    tools:text="(+27.69%)"
    />


<TextView
    android:id="@+id/tvTotalStockDifference"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="4dp"
    android:textSize="14sp"
    app:layout_constraintEnd_toStartOf="@+id/tvTotalStockPercent"
    app:layout_constraintTop_toBottomOf="@+id/tvTotalStockInvestment"
    tools:text="+3,28,234"
    />

<TextView
    android:id="@+id/tvDayStockDifference"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:textSize="14sp"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvTotalStockDifference"
    tools:text="-24,015"
    />


<TextView
    android:id="@+id/tvTitleDayStockDifference"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    tools:text="Today's Gain"
    android:textSize="14sp"
    app:layout_constraintEnd_toStartOf="@+id/tvDayStockDifference"
    app:layout_constraintTop_toBottomOf="@+id/tvTotalStockDifference" />

上面布局的输出: