How do I align the text in the text-area on bottom?

Viewed 207

I want to align the text of this two labels on it's bottom, so the two values are aligned on the same height.

Sadly, I dont find an option like aligning it inside its own area. gravity wont work. It has to be in xml.

Thank you!

<TextView
        android:id="@+id/feed_euro"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toStartOf="@+id/feed_cent"
        android:height="35dp"
        android:text="23"
        android:textColor="@color/colorTextBlack"
        android:textSize="25dp" />

    <TextView
        android:id="@+id/feed_cent"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:height="35dp"
        android:text=",39 €"
        android:textAlignment="textStart"
        android:textColor="@color/colorTextBlack" />
3 Answers

If you want to set your textview text bottom android:gravity="bottom"

or if you want to set your whole component bottom

android:layout_gravity="bottom"

To align the text inside a TextView to its bottom, you can use

android:gravity="bottom"

(inside TextView tags)

You can change the gravity to bottom like below.

<TextView
    android:id="@+id/feed_euro"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toStartOf="@+id/feed_cent"
    android:height="35dp"
    android:text="23"
    android:textColor="@color/colorTextBlack"
    android:textSize="25dp" />

<TextView
    android:id="@+id/feed_cent"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:height="35dp"
    android:text=",39 €"
    android:gravity="bottom"
    android:textAlignment="textStart"
    android:textColor="@color/colorTextBlack" />

And also you can try android:gravity="bottom" to the layout you have used to hold the both TextView and change the 2nd TextView height into wrap_content.

Hope you got the answer.

Related