I'm trying to get my text of my text view within the table row to appear on more than one line, but for some reason it doesn't wrap properly and I end up with this (see screenshot). I know the text view has something to do this it but I don't know what I causing this problem to occur. What can be done to resolve this issue?
Screenshot
List item XML
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow>
<ImageView
android:id="@+id/img"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:singleLine="false"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>
You need specify android:layout_weight="1"
.
This value is telling to
TableRow
that theTextView
is need to be equivalent tomatch_parent
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
>
<ImageView
android:id="@+id/img"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"/>
<TextView
android:id="@+id/txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_weight="1"
android:text="This is a long long long long text fodshfkjsdkjfjsh js hdfjksh kjdhf kjshdkjf"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</TableRow>
</TableLayout>
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