GridLayout Column width

前端 未结 6 1986
再見小時候
再見小時候 2021-02-11 12:27

I have 2 columns in my GridLayout. What I want to do is make those columns take up half of the width of the screen each and then have its child contents fill their

6条回答
  •  野性不改
    2021-02-11 13:05

    adding views dynamically in a grid Layout of 2 columns that take 50% of the available space:

    GridLayout gridLayout = new GridLayout();
    
    View view; //it can be any view
    
    GridLayout.LayoutParams param = new GridLayout.LayoutParams();
    
    param.columnSpec = GridLayout.spec(GridLayout.UNDEFINED,GridLayout.FILL,1f);
    
    param.width = 0;
    
    view.setLayoutParams(param);
    
    gridLayout.add(view);
    

    in static way (in .xml file).

    
    
    
    
    
    
    
    
    
    
    
    

提交回复
热议问题