I got the following layout, as well you can see my "View More" button is aligned exactly vertically center/middle of the bottom edge line.
app:layout_constraintBottom_toBottomOf="@id/iv_content"
app:layout_constraintTop_toBottomOf="@id/iv_content"
Now, what if I want to push my "View More" button slightly downward for about 2% of its height or 2dp for example.
I've tried android:layout_marginTop="50dp"
makes no different
app:layout_constraintVertical_bias="0.8"
makes no different either.
What else any "constraint solution" I can do, besides the old school method:
app:layout_constraintBottom_toBottomOf="parent"
(apply on btn_view_more
) and then hardcode the marginBottom
and push upward
I know this is one of the solutions but, I'm interested to know if any constraint related solution available that I'm not aware of
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_content"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginHorizontal="@dimen/_20sdp"
android:layout_marginVertical="@dimen/_50sdp"
android:background="@drawable/background_transparent_round_corner"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/iv_close"
android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp"
android:background="@drawable/background_circle"
android:src="@drawable/ic_close"
app:layout_constraintBottom_toTopOf="@id/iv_content"
app:layout_constraintEnd_toEndOf="@id/iv_content"
app:layout_constraintStart_toEndOf="@id/iv_content"
app:layout_constraintTop_toTopOf="@id/iv_content" />
<air.com.my.companyname.util.font.InterRegularButton
android:id="@+id/btn_view_more"
style="@style/ButtonSolidBlue"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/_40sdp"
android:layout_marginTop="50dp"
android:text="View More"
app:layout_constraintBottom_toBottomOf="@id/iv_content"
app:layout_constraintEnd_toEndOf="@id/iv_content"
app:layout_constraintStart_toStartOf="@id/iv_content"
app:layout_constraintTop_toBottomOf="@id/iv_content" />
</androidx.constraintlayout.widget.ConstraintLayout>