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

How to make table FullScreen? #218

Open ghost opened 5 years ago

ghost commented 5 years ago

I have a trouble with the width of a specific column/cell.. as we know, it is necessary to use: column_header_container.getLayoutParams().width = LinearLayout.LayoutParams.WRAP_CONTENT; to set the width of a column. It is possible to change it also to MATCH_PARENT. But.. what in the case that I want to set w width according to having full screen table? I have only 3 columns which take place of 1/3 of the screen's width.

On the other hand, with column_header_container.getLayoutParams().width = LinearLayout.LayoutParams.MATCH_PARENT; one column takes the rest of free width and without scrolling there is only first(main/category) column and that specific one..

I have a ConstraintLayout layout with: <com.evrencoskun.tableview.TableView android:id="@+id/content_container" android:layout_width="0dp" android:layout_height="0dp" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" />

but TableView takes as much space as WRAP_CONTENT for each columns is needed. Now, the Activity looks like: 56205063_895633287495230_1891034084218503168_n but I want: 55597550_2041960472772059_6662719574430973952_n

without hardcoding the width. Thanks for help :)

ghost commented 5 years ago

Hi @evrencoskun - have you got any idea? :) Is there any solution?

miloradtrninic commented 5 years ago

Hi @HubertLaczak , I have the same issue, have you found the solution?

surhidamatya commented 5 years ago

Hi @evrencoskun - How can I set width match parent programatically?

nitink133 commented 4 years ago

Any update?

egeysn commented 3 years ago

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 :)