3

I have a table layout with five columns and many rows with dynamic content.

We notice that each column takes the width of the maximum of all cells of that column.

I do not want horizontal scrolling but I want to detect when the total width has been exceeded so I can remove one of the columns.

Is this possible?

kabuko
  • 36,028
  • 10
  • 80
  • 93
Sherif elKhatib
  • 45,786
  • 16
  • 89
  • 106

2 Answers2

1

You could call measure() on the TableLayout yourself and check the result with getMeasuredWidth/Height.

Romain Guy
  • 97,993
  • 18
  • 219
  • 200
0

If you are adding each row in a loop, then I guess you could do something like:

int longestRowWidth = 0;

for(i=0; i<6; i++) 
{

    // Add your row here

    // Get the width of your new row here
    int rowWidth = blablah


    // Check if it exceeds longestRowWidth
    if(rowWidth > longestRowWidth)
    {
        // Do your stuff here.
    }
}
soren.qvist
  • 7,376
  • 14
  • 62
  • 91