I have 2 adjacent TextView
s, each with a different string that has a different font size. I want the text to have the same baseline in each TextView
. How can I do this?
Here is my layout:
<LinearLayout
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:background="@color/colorAccentLight"
android:textSize="18sp"
style="@style/Base.TextAppearance.AppCompat.Medium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="bottom"
android:textAlignment="gravity"
android:text="30"
/>
<TextView
android:background="@color/colorAccent"
android:text="hello"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="bottom"
android:textAlignment="gravity"
/>
</LinearLayout>
Here is the current behavior, notice how the 2 TextView
s have different baselines (the "hello" is lower than the 30) because the font for each TextView
is a different size.
In ConstraintLayout
you can simply use
app:layout_constraintBaseline_toBaselineOf="@+id/textView1"
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