ConstraintLayout忽略边距

Szy*_*ski 6 android android-constraintlayout

我的布局非常简单,可以用一个始终可用的RelativeLayout代替。但是,无论我在哪里放置边距,它们都会被忽略,不,我不想使用填充,不,链条也无法解决问题。任何的想法?

例如,日期或制造商的利润率以及其他利润率都将被忽略。

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    android:padding="8dp"
    app:cardBackgroundColor="?attr/szykColorSecondary"
    app:cardCornerRadius="8dp"
    app:cardElevation="4dp">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp">

        <TextView
            android:id="@+id/date"
            style="?attr/szyk_textMedium"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="32dp"
            android:gravity="left"
            android:singleLine="true"
            android:text="16.12.2014"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/manufacturer"
            style="?attr/szyk_textBody"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="32dp"
            android:paddingRight="8dp"
            android:text="Samsung"
            android:textAllCaps="true"
            android:textSize="24sp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toLeftOf="@+id/model"
            app:layout_constraintTop_toBottomOf="@+id/date" />

        <TextView
            android:id="@+id/model"
            style="?attr/szyk_textBody"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:gravity="left"
            android:text="S6 edge"
            android:textAllCaps="true"
            android:textSize="24sp"
            app:layout_constraintBottom_toBottomOf="@+id/manufacturer"
            app:layout_constraintLeft_toRightOf="@+id/manufacturer"
            app:layout_constraintRight_toLeftOf="@+id/delete"
            app:layout_constraintTop_toTopOf="@+id/manufacturer" />

        <ImageView
            android:id="@+id/delete"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_vector_delete"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/serial"
            style="?attr/szyk_textMedium"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:singleLine="true"
            android:text="FDSF6D7A8FDAS6F7D89AS"
            android:textSize="12sp"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/manufacturer" />

        <TextView
            android:id="@+id/restore"
            style="?attr/szyk_textButton"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="32dp"
            android:text="@string/restore"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/serial" />

    </android.support.constraint.ConstraintLayout>

</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)

compile 'com.android.support.constraint:constraint-layout:1.0.2'
Run Code Online (Sandbox Code Playgroud)

工具类

compileSdkVersion 27
buildToolsVersion '27.0.2'
Run Code Online (Sandbox Code Playgroud)

Szy*_*ski 1

对不起这是我的错。问题的根本原因是我一直使用的风格。它已经定义了android:layout_margin,它覆盖了所有更具体的边距,例如android:layout_marginTop

<item name="android:layout_margin">2dp</item>
Run Code Online (Sandbox Code Playgroud)