How to assign wrap_content as height to dynamically loaded gridview

前端 未结 5 2111
-上瘾入骨i
-上瘾入骨i 2021-01-14 08:31

I am loading gridview dynamically with buttons. So for that I am using scrollview, But if i assign wrap_content as height to gridview all the buttons are not displayed. I do

5条回答
  •  渐次进展
    2021-01-14 08:54

    try this

    int totalHeight = (count / );
    
        if (count %  != 0) {
            totalHeight++;
        }
    
        ViewGroup.LayoutParams params = gridview.getLayoutParams();
    
        params.height =  * totalHeight;
    
        gridview.setLayoutParams(params);
        gridview.requestLayout();
    

提交回复
热议问题