Is it possible to align the bottom of an ImageView
to the baseline of a TextView
using a ConstraintLayout
? It used to be easy with a RelativeLayout
but it seems to be gone from ConstraintLayout
. :(
yes, it can be achieved in constraintLayout using
android:baselineAlignBottom="true"
app:layout_constraintBaseline_toBaselineOf="@+id/textView"
please check below code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="52dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:baselineAlignBottom="true"
app:layout_constraintBaseline_toBaselineOf="@+id/textView33"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.815"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/home_96" />
<TextView
android:id="@+id/textView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.59"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With