evrencoskun / TableView

TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.
MIT License
3.14k stars 459 forks source link

Cell height is not matching with row header and separator not visible #151

Closed naushad-madakiya closed 6 years ago

naushad-madakiya commented 6 years ago

I have dynamic content for row headers where in some cases content can be longer than screen size. I saw in a sample where height & content is predefined.

1) Is there any way where cell height can be the same as row header? 2) divider for row header and column header are not visible, did I missed anything?

following is the screenshot of current UI I have implemented.

screenshot_20180821-18095- copy

naushad-madakiya commented 6 years ago

@evrencoskun @sonique6784 guys any idea? I have gone through all the issues and doc but couldn't understand why this is happening

sonique6784 commented 6 years ago

@naushad-madakiya I think row height is set with layout_height inside your row_header and cell layouts. So make sure the heigh of row_header and cell layout match.

In addition, given you layout, you should consider setting a larger RowHeader width. this can be done in your layout with layout_width, or dynamically in the code with getTableView().setRowHeaderWidth()

evrencoskun commented 6 years ago

Hi @naushad-madakiya,

In TableView, there is no any control to checks the cell height of both of row headers and centre cells. I

So, as @sonique6784 said, you have to be sure they have the same size.

So, you have 2 options that I've just come to my mind;

  1. The TextView of the Row Header will not wrap the text. using this android:maxLines="1"and set much larger width.
  2. You will set the same height value for both cell items of Row Headers and Centre Cells.
naushad-madakiya commented 6 years ago

after setting up fix values for row_header_width and column_header_height cell width was matching to column header but cell height is not matching with row header as row header has more content than column header.

I applied the following to make cell height and width dynamic

    @Override
    public void onBindCellViewHolder(AbstractViewHolder holder, Object cellItemModel, int columnPosition, int rowPosition) {

        // It is necessary to remeasure itself.
        View columnHeaderView = columnHeaderLayoutManager.findViewByPosition(columnPosition);
        View rowHeaderView = rowHeaderLayoutManager.findViewByPosition(rowPosition);

        // set dynamic height and width to cell view
        holder.itemView.getLayoutParams().width = columnHeaderView.getWidth();
        holder.itemView.getLayoutParams().height = rowHeaderView.getHeight();

        holder.itemView.requestLayout();
    }