Firstly, I did a Google search and looked at StackOverFlow questions related to text being cut off for TextView
. They did not help to solve the problem at hand, though they provided better understanding of certain things.
Here is my problem.
I am using TableLayout
to display records with two text fields. Each row has two TextView
cells. layout_width
is set to wrap_content
for all cells. But, even though the text is displayed in multiple lines, every line in that multi-line text is cut off at the end.
e.g.
<?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="wrap_content">
<TableRow>
<TextView
android:text="Notes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/visitation_notes" />
<TextView
android:text="Need to visit again. Visit till the doctor understands the importance of the Test. The problem is, it is very difficult to get appointment for the visit. Still, we need to keep trying till the point reaches to him/her."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/visitation_notes_value"
android:textAlignment="viewStart"/>
</TableRow>
</TableLayout>
produced the view
Notes.Need to visit again. Visit till the doctor understands the importance of the Test. The problem is, it is very difficult to get appointment for the visit. Still, we need to keep trying till the point reaches to him/her.
with the text written in bold getting cut off.
If I use LinearLayout
in place of TableLayout
, it works fine. But, the problem with that is I can't have second column of each row starting at same position(with no hardcoding).
Please help me how to make sure TextView
content won't get cut off.
Here is the screenshot of view produced for example given above.
Do this
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Note" />
<TextView
android:layout_weight="3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:text="Need to visit again. Visit till the doctor understands the importance of the Test. The problem is, it is very difficult to get appointment for the visit. Still, we need to keep trying till the point reaches to him/her." />
</TableRow>
I got the truncated TextView
inside a TableRow
element issue resolved with the following code:
<TableRow>
<TextView
android:layout_gravity="right"
android:text="Address: "
android:textStyle="bold"/>
<TextView
android:id="@+id/address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingRight="10dp"
android:text="123 W. Abc St., San Diego CA 90333"/>
</TableRow>
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