tejpratap46/PDFCreatorAndroid

Custom width for a single column

Closed this issue · 2 comments

How to customize the width for the columns, so that the widths of each column are not the same

There is no straight forward way to achieve this, you can hack your way out by setting custom layout weight. But you have to intelligently set same weight to every TextView in same position of every row.

pdfTextView.setLayout(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 2 /* CUSTOM COLUMN WEIGHT */));

Insert above code after you added Item to Row. As while adding Item to Row, I reset weight to 1.

tableRowView.addToRow(pdfTextView);

I will look into possibilities of adding custom weight to table columns while initializing.

Can set custom column with to Table View

PDFTableView tableView = new PDFTableView(getApplicationContext(), tableHeader, tableRowView1);
// as this table has 4 columns, each will get width as per their index in array.
// Sum should be equal to 100%
int[] widthPercent = {20, 20, 20, 40};
tableView.setColumnWidth(widthPercent);