Sherif elKhatib
Sherif elKhatib

Reputation: 45942

TableLayout Tweak. Is it possible?

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?

Upvotes: 3

Views: 213

Answers (2)

Romain Guy
Romain Guy

Reputation: 98501

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

Upvotes: 1

soren.qvist
soren.qvist

Reputation: 7416

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.
    }
}

Upvotes: 0

Related Questions