microflakes
microflakes

Reputation: 313

Multiline textview in Tablelayout moving the textview

I have a table layout with this textView:

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TableRow>

        <TextView
            android:layout_width="0dp"
            android:layout_height="48dp"
            android:layout_weight=".25"
            android:gravity="center"
            android:text="line1 \nline2"
            android:textAppearance="@style/TextAppearance.AppCompat.Body2" />

But the textview shifts downwards. I'd like it to simply be like the others, but with 2 lines of text, centered in the textView.

enter image description here

Upvotes: 0

Views: 52

Answers (1)

Md. Asaduzzaman
Md. Asaduzzaman

Reputation: 15433

Add layout_gravity to center with two line TextView like below:

<TextView
    android:layout_width="0dp"
    android:layout_height="48dp"
    android:layout_weight=".25"
    android:gravity="center"
    android:layout_gravity="center"
    android:text="line1 \nline2"
    android:textAppearance="@style/TextAppearance.AppCompat.Body2" />

Upvotes: 1

Related Questions