First see the layout for my point
Here is 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>
I want to put some space between bankInfoHeadingTV and bankInfoIconIV.
So it put the margin of 30dp at the end of bankInfoHeadingTV but it is not working.
Margin start with bankInfoIconIV is working but why margin end with bankInfoHeadingTV is not working?
You can only set margins for a view if you have the constraint. Because you constrained your ImageViews start to the end of textView you can set the start margin for the image. If you reversed it and constrained the end of yout TextView to the ImageView you can set the margin in the TextView.