SortableTableView icon indicating copy to clipboard operation
SortableTableView copied to clipboard

Column Weight problem

Open ulaserdegor opened this issue 7 years ago • 13 comments

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?

screenshot_1479380963 screenshot_1479380968

ulaserdegor avatar Nov 17 '16 11:11 ulaserdegor

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

ISchwarz23 avatar Nov 17 '16 18:11 ISchwarz23

Yes!!! @ISchwarz23 Thanks again. screenshot_1479456748 screenshot_1479456757

ulaserdegor avatar Nov 18 '16 08:11 ulaserdegor

@ISchwarz23 but :/

There was a problem with the screens in different resolutions. 23232

ulaserdegor avatar Nov 18 '16 08:11 ulaserdegor

I'm currently working on a soltion. A version 2.4.1 will be released today or latest tomorrow :)

ISchwarz23 avatar Nov 18 '16 13:11 ISchwarz23

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

ISchwarz23 avatar Nov 18 '16 15:11 ISchwarz23

Yes!!! You are the best. Certainly one of the most useful libraries.

Problem resolved.

Let's code

image

ulaserdegor avatar Nov 21 '16 06:11 ulaserdegor

Thank you very much :)

ISchwarz23 avatar Nov 21 '16 11:11 ISchwarz23

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

img_2110 img_2114

ulaserdegor avatar Nov 22 '16 17:11 ulaserdegor

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?

ISchwarz23 avatar Nov 23 '16 14:11 ISchwarz23

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. :/

19a25c0c-b0ed-11e6-88d5-fbba23c615e6

ulaserdegor avatar Nov 23 '16 14:11 ulaserdegor

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)

ISchwarz23 avatar Nov 23 '16 16:11 ISchwarz23

Yes. I m using TableColumnDpWidthModel. But you call toPixel(int dp) inside the class 😕

ulaserdegor avatar Nov 23 '16 16:11 ulaserdegor

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 .

ulaserdegor avatar Nov 24 '16 11:11 ulaserdegor