Open ghost opened 5 years ago
any progress bro?I met the same problem
I am trying to figure this out also
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
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.
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 :)
How to set column width match the screen width?