页边距末尾/右边不在约束布局中的项上工作



首先查看我的点的布局

在此处输入图像描述

这是XML

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/mainCL"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/appBarLayout"
>
<TextView
android:id="@+id/bankInfoHeadingTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="36dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="8dp"
android:fontFamily="@font/montserrat_semibold"
android:text="Bank Information"
android:textColor="@color/black"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/bankInfoIconIV"
android:layout_width="42dp"
android:layout_height="32dp"
android:src="@drawable/card"
app:layout_constraintBottom_toBottomOf="@id/bankInfoHeadingTV"
app:layout_constraintStart_toEndOf="@id/bankInfoHeadingTV"
app:layout_constraintTop_toTopOf="@id/bankInfoHeadingTV" />
</androidx.constraintlayout.widget.ConstraintLayout>

我想在bankInfoHeadingTVbankInfoIconIV之间留出一些空间
所以它在bankInfoHeadingTV的末尾设置了30dp的裕度,但它不起作用
bankInfoIconIV开始的保证金有效,但为什么以bankInfoHeadingTV结束的保证金无效?

只有在有约束的情况下才能为视图设置边距。由于您将ImageViews的起始位置限制在textView的末尾,因此可以设置图像的起始边距。如果将其反转并将您的TextView的末尾约束为ImageView,则可以在TextView中设置边距。

最新更新