开发者

TableLayout Tweak. Is it possible?

开发者 https://www.devze.com 2023-03-22 20:57 出处:网络
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 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.
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消