TableView icon indicating copy to clipboard operation
TableView copied to clipboard

How to set column width match the screen width?

Open ghost opened this issue 7 years ago • 5 comments

How to set column width match the screen width?

ghost avatar Dec 25 '18 08:12 ghost

any progress bro?I met the same problem

ChaoquanTao avatar Dec 25 '18 14:12 ChaoquanTao

I am trying to figure this out also

ronnie173 avatar Dec 28 '18 17:12 ronnie173

Fair warning. I'm still getting familiar with this view.

I was able to get 1 column to take up the whole screen by adding this into my ColumnHeaderViewHolder class inside setColumnHeaderModel:

column_header_container.layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT
column_header_textview.requestLayout()

Then inside my CellHolder inside function setCellModel:

cell_container.layoutParams.width= MATCH_PARENT 
cell_textView.requestLayout()

This is assuming that your Table View has a layout_width of match_parent

TheRealChrisThomas avatar Jan 14 '19 03:01 TheRealChrisThomas

If you want to give a certain width to every column, you can calculate the width of the device then you do a division by the numbers of columns so they can fit the whole screen width.

naitbrahim avatar Feb 18 '19 08:02 naitbrahim

While i using to table with four header it was not covering the page.I solved this problem following methods. Optional(I hide the all row items in the table) - binding.myTableView.setAdapter(mTableAdapter); binding.myTableView.setRowHeaderWidth(0); in MyTableViewAdapter:

public MyTableViewAdapter(Context context, int size) { // size :: for dynamic header items
    mContext = context;
    screenWidth = utils.getScreenWidth();
    headerWidth = (int) (screenWidth / size);
}

later i sent header width to Header


public ColumnHeaderViewHolder(TableviewColumnHeaderLayoutBinding binding) {
            super(binding.getRoot());
            this.binding = binding;
        }
        public void setColumnHeaderModel(ColumnHeaderModel key, int pColumnPosition) {
            // Set text data
            binding.columnHeaderTextView.setText(key.getData());
            //   binding.columnHeaderContainer.getLayoutParams().width = LinearLayout.LayoutParams.WRAP_CONTENT; 
              i changed this code to this-->
            binding.columnHeaderContainer.getLayoutParams().width = headerWidth;
            binding.columnHeaderTextView.requestLayout();
        }

OK , nice works :)

egeysn avatar Mar 01 '21 19:03 egeysn