Search code examples
androidclippingtablerow

Android: Tablerow multiline textview clipping vertically


I am dynamically adding rows with two columns to a table. One of the columns holds text that will spread across multiple lines. I've added the weight on the layout parameters for the textview so it no longer clipps outside of the screen, but it seems to be restricted to two and a half lines showing in the table, regardless of how long the multiline text is. The table is just defined in xml and everything else is done programmatically.

    TableRow.LayoutParams rowParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
    TableRow.LayoutParams paramsStar = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
    paramsStar.setMargins(0,0,40,0);
    TableRow.LayoutParams paramsText = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.FILL_PARENT, (float)1.0);

    TableRow tr = new TableRow(this);
    tr.setLayoutParams(rowParams);

    TextView viewStar = new TextView(this);
    viewStar.setTextSize((float) 30.0);
    viewStar.setText("*");
    viewStar.setLayoutParams(paramsStar);
    viewStar.setTypeface(Typeface.DEFAULT_BOLD, 2);

    TextView viewText = new TextView(this);
    viewText.setText("Long multiline text piece"); //<--- Here the long text goes
    viewText.setLayoutParams(paramsText);

    tr.addView(viewStar);
    tr.addView(viewText);
    table.addView(tr, rowParams);

How do i fix this vertical clipping? Screenshot of the problem below:

Here is the link showing the problem


Solution

  • I've found the root of the problem. The first column values textsize made the multiline text clip. If i reduce the textsize, the problem disappears. I cant explain why though.