SortableTableView
SortableTableView copied to clipboard
Column Weight problem
Hi. Thanks for lib.
I using table in horizontal scroolview, on landscape screen. Because i have 9 columns.
But, i can not give it the width I want.
setColumnWeight(0, 3); setColumnWeight(1, 3); setColumnWeight(2, 3); setColumnWeight(3, 4); setColumnWeight(4, 4); setColumnWeight(5, 4); setColumnWeight(6, 4); setColumnWeight(7, 5); setColumnWeight(8, 5);
What do I have to do to make sure all the columns are visible?
Hi @ulaslaslas,
please update to the version 2.4.0 of this library and use the TableColumnWidthModel
. This TableColumnModel
implementation allows to define absolute widths for each column.
Usage is simple as that:
TableColumnWidthModel tableColumnModel = new TableColumnWidthModel( 9 );
tableColumnModel.setColumnWidth( 0, 300 );
// define other column widths here
setColumnModel( tableColumnModel );
Please tell me if this fulfilled your needs.
Best regards, Ingo
Yes!!! @ISchwarz23 Thanks again.
@ISchwarz23 but :/
There was a problem with the screens in different resolutions.
I'm currently working on a soltion. A version 2.4.1 will be released today or latest tomorrow :)
Hi @ulaslaslas,
please update to the version 2.4.1 of this library and use the TableColumnDpWidthModel
. This TableColumnModel
implementation allows to define absolute widths for each column in density-independent pixels.
Usage is simple as that:
TableColumnDpWidthModel tableColumnModel = new TableColumnDpWidthModel( getContext(), 9 );
tableColumnModel.setColumnWidth( 0, 200 );
// define other column widths here
setColumnModel( tableColumnModel );
Please tell me if this fulfilled your needs now completely :P
Best regards, Ingo
Yes!!! You are the best. Certainly one of the most useful libraries.
Problem resolved.
Let's code
Thank you very much :)
Hi again. İ get errors on different screens. Tablecolumnwidthdp method is give dp. But inside Convert to pixel. Why? Andorid Layout_width needed dp. But columns change dp to px 😕 Screenshot from asus zenfone2
The difference between the width of the lower TextView and the width of the columns is the difference on the high resolution phone. Because one dp one is px
Yes, internally the TableView
is handling all widths in pixels. The different TableColumnModel
as an abstraction, that is holding the defined column widths in different presentations e.g. px and dp.
But I didn't understand exactly where the issue is. What have you expected, and what differs from that expectation?
Both are 200dp in width as in the picture. But it is not the same width. The following TextView show my total values. And it needs to be aligned with the column. :/
Hi again :)
execuse me, but I have to ask this question: Are you sure you are using the TableColumnDpWidthModel and not the TableColumnPxWidthModel?
(I have to ask this before I start the investigation)
Yes. I m using TableColumnDpWidthModel. But you call toPixel(int dp) inside the class 😕
private int toPixel(final int dp) { return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); }
I think the problem is here. Because DENSITY_DEFAULT = 160 . But this value is different for each device. 400 for asus zenfone2 .