簡體   English   中英

邊距結束/右邊不適用於約束布局中的項目

[英]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>

我想在bankInfoHeadingTVbankInfoIconIV之間放置一些空間。
所以它將 30dp 的邊距放在bankInfoHeadingTV的末尾,但它不起作用。
bankInfoIconIV開頭的保證金有效,但為什么以bankInfoHeadingTV結尾的保證金無效?

如果您有約束,您只能為視圖設置邊距。 因為您將 ImageViews 限制在 textView 的末尾,您可以設置圖像的起始邊距。 如果您反轉它並將您的 TextView 的結尾限制為 ImageView 您可以在 TextView 中設置邊距。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM