[英]margin end/right is not working on item in constraint layout
首先看一下我的觀點的布局
這是 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>
我想在bankInfoHeadingTV和bankInfoIconIV之間放置一些空間。
所以它將 30dp 的邊距放在bankInfoHeadingTV的末尾,但它不起作用。
以bankInfoIconIV開頭的保證金有效,但為什么以bankInfoHeadingTV結尾的保證金無效?
如果您有約束,您只能為視圖設置邊距。 因為您將 ImageViews 限制在 textView 的末尾,您可以設置圖像的起始邊距。 如果您反轉它並將您的 TextView 的結尾限制為 ImageView 您可以在 TextView 中設置邊距。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.