Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top