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?
You could call measure() on the TableLayout yourself and check the result with getMeasuredWidth/Height.
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.
}
}
精彩评论