0

I have a TableLayout where each TableRow contains an ImageView and a TextView. I want to let the TextViews expand into multiple lines if their content will not fit in one line.

I tried many different attribute settings such as setting the TextView to wrap_content, maxLines, scrollHorizontal = false, and no ellipsis. I tried setting the TableView to wrap_content as well but no luck. Everything that I can find online seems to be about a TextView not nested in a TableLayout, so I don't know if the TableLayout settings is interfering with other answers. The closest related question I can find is here, but it didn't work for me.

Below is my XML for the TableLayout:

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginBottom="8dp"
    android:gravity="center_vertical|start"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="5dp">

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.15"
            app:srcCompat="@drawable/ic_info_24px" />

        <TextView
            android:id="@+id/AdditionalInfo"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_span="3"
            android:layout_weight="0.85"
            android:gravity="center_vertical|start"
            android:text="Additional Info that can potentially be too much for one line"
            android:textSize="16sp" />

    </TableRow>

</TableLayout>

1 Answers1

0

Try to add attribute android:inputType="textMultiLine" to TextView. And in the attribute android:layout_height you set "match_parent" change to "wrap_content".

  • I was going to say I tried the textMultiLane, but then realized that I didn't have my height set to wrap_content. Thanks, it works! – devthedevel Dec 21 '18 at 18:42