7

I'm having a problem with the TableLayout.

First, take a look at the screenshot:

Screenshot

As you can see, there is a pretty big space in the middle of the TableLayout. I don't know how to reduce the space in the middle, so that the TableRows will have more Width to cover. And also, I want to reduce the space between a TableRow and the one below it.

I'm adding the views to the TableLayout programmatically. Also, I've already set the 'layout_weight' of the content of the TableRow to 1f:

TableRow tr = (TableRow) new TableRow(mTableLayout.getContext());
TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
NormalCard card = new NormalCard();
card.setLayoutParams(new TableRow.LayoutParams(0, 740, 1f));
tr.addView(card);
mTableLayout.addView(tr, params);

XML declaration of the TableLayout:

<TableLayout
            android:id="@+id/tableLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:shrinkColumns="*"
            android:stretchColumns="*"
            android:dividerPadding="0dp"
            android:showDividers="none"
            android:divider="@null">
        </TableLayout>

How do I reduce the space in the middle of the TableLayout. And also, How to reduce the space between a TableRow and the one below it.

Thank you upfront.

Eli Revah
  • 3,626
  • 7
  • 27
  • 33

2 Answers2

0

Please specify your table layout xml file you have just shown images.

try this if it works

android:shrinkColumns="*"  
android:stretchColumns="*"

in your TableLayout tag.

okay try to set padding as 0 to your table row if no of column in each row is same then specify table width as wrap_content.

CodingRat
  • 1,934
  • 3
  • 23
  • 43
0

Have a try with this:

params.setMargins(0, 0, 0, 0);
print x div 0
  • 1,474
  • 1
  • 15
  • 33