How to draw horizontal and vertical line in Table layout

后端 未结 1 1963
情歌与酒
情歌与酒 2021-01-05 06:01

I want a vertical and horizontal line drawn inside the a table row.

i cant attach image

i tried drawing lines around TextView in table

1条回答
  •  被撕碎了的回忆
    2021-01-05 06:15

    For horizontal line

    view v = new View(this);
                v.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, 1));
    

    For Vertical line

     view v = new View(this);
     v.setLayoutParams(new TableRow.LayoutParams(1, TableRow.LayoutParams.MATCH_PARENT));
    

    add this in your code and add it to table row Programmatically

    Edited:

    TableRow row;
    row=(TableRow)findViewById(R.id.traningprogram_tableRow_mondayHeading);
    row.addView(v);
    

    if you want to create it in xml itself use this code after your each row items(TextView)

    for Horizontal line in XML

    
    

    for vertical line in XML

    
    

    Try this it will work

    0 讨论(0)
提交回复
热议问题