I have a TextView inside a TableRow. The text contained in this TextView is tipically larger than the screen. As such, I would like for the the text to wrap into multiple lines.
TableLayout table = (TableLayout)findViewById(R.id.myTable);
TableRow row = new Tablerow(context);
TextView view = new TextView(context);
view.setText(stringWithLotsOfCharacters);
view.setSingleLine(false);
row.add(view);
table.addview(row, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
I tried using "setSingleLine" but it does not have the effect I was looking for.
Any suggestions? Thanks.
Add android:shrinkColumns="1"
for the column you want to wrap to the TableLayout in your layout or android:shrinkColumns="*"
if you want to wrap all columns.
You can also do it programmatically with setColumnShrinkable:
public void setColumnShrinkable (int columnIndex, boolean isShrinkable)
view.setHeight(LayoutParams.WRAP_CONTENT);
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