删除约束布局中链式视图中两个视图之间的 space

Remove space between two views in chained view in constraint layout

我在约束布局中使用链式视图。现在我希望两个文本视图之间的中间 space 为 removed.As 底部的按钮距离较远。我试图将它们从设计布局中移走,但它并没有发生。怎么做it.Following是我的xml

<?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"
    tools:layout_editor_absoluteY="81dp">


    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="23dp"
        android:layout_marginStart="32dp"
        android:gravity="center"
        android:text="TextView"
        app:layout_constraintBottom_toBottomOf="@+id/imageView3"
        app:layout_constraintStart_toEndOf="@+id/imageView3" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="26dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView2"
        app:srcCompat="@mipmap/ic_launcher_round" />

    <TextView
        android:id="@+id/textViewHeader"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="TextView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <!--<LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="1dp"
        android:layout_marginStart="20dp"
        android:layout_marginTop="60dp"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@id/linearLayout2">-->


    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="25dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="70dp"
        app:layout_constraintEnd_toStartOf="@+id/textView2"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@mipmap/ic_launcher_round" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginStart="32dp"
        android:layout_marginTop="26dp"
        android:gravity="center"
        android:text="TextView"
        app:layout_constraintStart_toEndOf="@+id/imageView2"
        app:layout_constraintTop_toTopOf="@+id/imageView2" />

    <!-- </LinearLayout>-->

    <!--  <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="1dp"
        android:layout_marginStart="20dp"
        android:layout_marginTop="60dp"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="@id/linearLayout"
       >-->


    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="30dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView"
        app:srcCompat="@mipmap/ic_launcher_round" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="0dp"
        android:layout_height="17dp"
        android:layout_gravity="center"
        android:layout_marginBottom="58dp"
        android:layout_marginEnd="213dp"
        android:layout_marginTop="58dp"
        android:gravity="center"
        android:text="TextView"
        app:layout_constraintBottom_toTopOf="@+id/imageView2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/imageView"
        app:layout_constraintTop_toBottomOf="@+id/textViewHeader" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="67dp"
        android:layout_marginStart="90dp"
        android:gravity="center"
        android:text="TextView"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="63dp"
        android:layout_marginEnd="89dp"
        android:gravity="center"
        android:text="TextView"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/textView4" />

    <!-- </LinearLayout>-->

</android.support.constraint.ConstraintLayout>

底部有两个文本视图,水平放置,它们之间有 space。非常感谢:)

您必须添加 Guideline

<?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"
    tools:layout_editor_absoluteY="81dp">


    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginBottom="23dp"
        android:layout_marginStart="32dp"
        android:gravity="center"
        android:text="TextView"
        app:layout_constraintBottom_toBottomOf="@+id/imageView3"
        app:layout_constraintStart_toEndOf="@+id/imageView3" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="26dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView2"
        app:srcCompat="@mipmap/ic_launcher_round" />

    <TextView
        android:id="@+id/textViewHeader"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="TextView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <!--<LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="1dp"
        android:layout_marginStart="20dp"
        android:layout_marginTop="60dp"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@id/linearLayout2">-->


    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="25dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="70dp"
        app:layout_constraintEnd_toStartOf="@+id/textView2"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@mipmap/ic_launcher_round" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginStart="32dp"
        android:layout_marginTop="26dp"
        android:gravity="center"
        android:text="TextView"
        app:layout_constraintStart_toEndOf="@+id/imageView2"
        app:layout_constraintTop_toTopOf="@+id/imageView2" />

    <!-- </LinearLayout>-->

    <!--  <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="1dp"
        android:layout_marginStart="20dp"
        android:layout_marginTop="60dp"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="@id/linearLayout"
       >-->


    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="30dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView"
        app:srcCompat="@mipmap/ic_launcher_round" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="0dp"
        android:layout_height="17dp"
        android:layout_gravity="center"
        android:layout_marginBottom="58dp"
        android:layout_marginEnd="213dp"
        android:layout_marginTop="58dp"
        android:gravity="center"
        android:text="TextView"
        app:layout_constraintBottom_toTopOf="@+id/imageView2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/imageView"
        app:layout_constraintTop_toBottomOf="@+id/textViewHeader" />

<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="67dp"
    android:gravity="center"
    app:layout_constraintEnd_toStartOf="@+id/guideline1"
    android:text="TextView"
    app:layout_constraintBottom_toBottomOf="parent" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="63dp"
    android:gravity="center"
    android:text="TextView"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toEndOf="@+id/guideline1" />

<android.support.constraint.Guideline
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/guideline1"
    android:orientation="vertical"
    app:layout_constraintGuide_percent="0.5"/>

    <!-- </LinearLayout>-->

</android.support.constraint.ConstraintLayout>

关于约束布局中的指南: Utility class 表示 ConstraintLayout 的 Guideline 辅助对象。助手对象不会显示在设备上(它们被标记为 View.GONE)并且仅用于布局目的。它们只在 ConstraintLayout 中工作。 [...]

更多细节,有很好的文档:

https://developer.android.com/reference/android/support/constraint/Guideline.html

要删除两个链接视图之间的 space,只需将以下行添加到链中的第一项:

app:layout_constraintHorizontal_chainStyle="packed"

要阅读有关链式样式的更多信息: