TableRow span not working for dynamically added rows

前端 未结 2 512
长情又很酷
长情又很酷 2021-01-18 17:51

I have the following problem spanning dynamically added rows to a TableLayout inside a scroll view. The rows follow this pattern:

Row 1: Cell spanned over the whole

2条回答
  •  生来不讨喜
    2021-01-18 18:12

    May be it will help to somebody. Even this question was more than 2 years I see the same bug right now. That is, rowSpanLayout.span = 2; doesn't work. But in xml layout_span it works. I found the workable solution: 1. create the layour xml file injection with layout properties:

     
         
              
         
         
    
    1. Get Layout properties from this layout element:
    TableRow.LayoutParams blp;
    blp = (TableRow.LayoutParams)check1.getLayoutParams();
    blp.width = 100;
    blp.height = 50;
    TextView tw = new TextView(this);
    tw.setTextSize(tsEL);
    tw.setLayoutParams(blp);
    tw.setText(R.string.empty);
    tr.addView(tw);
    

    It works.

提交回复
热议问题