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.13k stars 453 forks source link

vertical and horizontal scroll bars are missing #368

Open Charith424 opened 3 years ago

Charith424 commented 3 years ago

Vertical and horizontal scroll bars are not showing in table view

I have pull "TableViewSampleApp" and tried to add horizontal and vertical scroll bars but those two bars are not showing up in table view.

To Reproduce Steps to reproduce the behavior:

  1. Take a pull from 'Table View Sample App'
  2. Added the scroll bars from xml

Code

   <com.evrencoskun.tableview.TableView
        android:id="@+id/my_TableView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:scrollbars="vertical|horizontal"
        android:scrollbarThumbVertical="@android:color/darker_gray" 
        android:scrollbarSize="5dp"
        app:column_header_height="@dimen/table_view_cell_height"
        app:row_header_width="@dimen/table_view_row_header_width"
        app:selected_color="@color/selected_background_color"
        app:shadow_color="@color/shadow_background_color"
        app:unselected_color="@color/unselected_background_color"
        app:separator_color="@color/separator_color"

        />

I have newly added below lines to table view for enable scroll bars

        android:scrollbars="vertical|horizontal"
        android:scrollbarThumbVertical="@android:color/darker_gray" 
        android:scrollbarSize="5dp"

Expected behavior Scroll bars should be visible.It will help user to look and feel table can scroll to horizontally or vertically.

Screenshots IssuCapture

Tools:

Zardozz commented 3 years ago

Not a Bug, TableView does not have this feature

Charith424 commented 3 years ago

As a user experience, how does a user know a table has more columns horizontally and more rows vertically?

Zardozz commented 3 years ago

Yes a useful feature, but this should be a feature request to try and get it added.

Zardozz commented 3 years ago

Due to the structure to the Table I don't think it would be easy to get scrollbars in those locations.

A quick hack to the library can add scrollbars in the headers to indicate the table is scrollable e.g. (scrollbars circled in red) image

It will take a bit more work to expose this capability to the App using TableView BUT as lots of new functionality has been added to TableView BUT no release has been made with this new functionality you are probably going to custom built the library yourself for the App to get any new functionality.

Note these can be styled like a standard recyclerview scrollbar

Charith424 commented 3 years ago

I have tried wrapping table view by HorizontalScrollView It is working partially showing horizontal bar but If the table has more columns horizontally than screen size those columns are hiding   

<HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
 <com.evrencoskun.tableview.TableView
        android:id="@+id/my_TableView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:scrollbars="vertical|horizontal"
        android:scrollbarThumbVertical="@android:color/darker_gray" 
        android:scrollbarSize="5dp"
        app:column_header_height="@dimen/table_view_cell_height"
        app:row_header_width="@dimen/table_view_row_header_width"
        app:selected_color="@color/selected_background_color"
        app:shadow_color="@color/shadow_background_color"
        app:unselected_color="@color/unselected_background_color"
        app:separator_color="@color/separator_color"

        /></HorizontalScrollView>
zxc503 commented 2 years ago

create a xml file cellrecycleview.xml

<?xml version="1.0" encoding="utf-8"?>
<com.evrencoskun.tableview.adapter.recyclerview.CellRecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scrollbars="vertical"/>

in class CellRecyclerView create a new constructer

public CellRecyclerView(@NonNull Context context, @Nullable  AttributeSet attrs) {
        super(context, attrs);

        // These are necessary.
        this.setHasFixedSize(false);
        this.setNestedScrollingEnabled(false);
        // These are for better scrolling process.
        this.setItemViewCacheSize(context.getResources().getInteger(R.integer
                .default_item_cache_size));
        this.setDrawingCacheEnabled(true);
        this.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
    }

in TableView.createCellRecyclerView() functrion

delete CellRecyclerView recyclerView = new CellRecyclerView(getContext()); add CellRecyclerView recyclerView = (CellRecyclerView) LayoutInflater.from(getContext()).inflate(R.layout.cellrecycleview, null);

image

Geethu7777 commented 1 year ago

Is there a way to implement horizontal scrollview indicator for the content

Geethu7777 commented 1 year ago

I have tried wrapping table view by HorizontalScrollView It is working partially showing horizontal bar but If the table has more columns horizontally than screen size those columns are hiding   

<HorizontalScrollView
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       >
<com.evrencoskun.tableview.TableView
       android:id="@+id/my_TableView"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_gravity="center"
       android:scrollbars="vertical|horizontal"
       android:scrollbarThumbVertical="@android:color/darker_gray" 
       android:scrollbarSize="5dp"
       app:column_header_height="@dimen/table_view_cell_height"
       app:row_header_width="@dimen/table_view_row_header_width"
       app:selected_color="@color/selected_background_color"
       app:shadow_color="@color/shadow_background_color"
       app:unselected_color="@color/unselected_background_color"
       app:separator_color="@color/separator_color"

       /></HorizontalScrollView>

Did you got any solution to add horizondal scroll indicator

aadi-github commented 1 year ago

Hi guys, I might have found something that we can use to enable scrollbars and if you want to change the default scrollbar drawable it will be possible on Android Q.....without importing Library.

/*Column ScrollBar*/ CellRecyclerView columnRecyclerView = tableView.getColumnHeaderRecyclerView(); columnRecyclerView.setHorizontalScrollBarEnabled(true); columnRecyclerView.setScrollbarFadingEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { columnRecyclerView.setHorizontalScrollbarThumbDrawable(AppCompatResources .getDrawable(context, R.drawable.table_scroll_bar_thumb_drawable)); columnRecyclerView.setHorizontalScrollbarTrackDrawable(AppCompatResources .getDrawable(context, R.drawable.table_scroll_bar_track_drawable)); } columnRecyclerView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); /*Row ScrollBar*/ CellRecyclerView rowRecyclerView = tableView.getRowHeaderRecyclerView(); rowRecyclerView.setVerticalScrollBarEnabled(true); rowRecyclerView.setScrollbarFadingEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { rowRecyclerView.setVerticalScrollbarThumbDrawable(AppCompatResources .getDrawable(context, R.drawable.table_scroll_bar_thumb_drawable)); rowRecyclerView .setVerticalScrollbarTrackDrawable(AppCompatResources.getDrawable(context, R.drawable.table_scroll_bar_track_drawable)); } rowRecyclerView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

Well I am still looking to enable drag but not yet found. Please help if any one got it enabled or else I might need to import.

luuuzi007 commented 10 months ago

I haven't thought of a better way to implement it yet. The way I implement it is

  1. Set the height of mColumnHeaderRecyclerView to LayoutParams.MATCH_PARENT,
  2. Set the layoutParams.bottomMargin of mRowHeaderRecyclerView and mCellRecyclerView to the height of the scrollbar.
  3. Set the scrollbar of mColumnHeaderRecyclerView

recyclerview_horizontal.xml

<?xml version="1.0" encoding="utf-8"?>
<com.evrencoskun.tableview.adapter.recyclerview.CellRecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scrollbars="horizontal"
    android:scrollbarSize="@dimen/scrollbar_windth2"
    android:scrollbarStyle="insideOverlay"
    android:scrollbarThumbHorizontal="@drawable/thumb"
    android:scrollbarTrackHorizontal="@drawable/track"/>

在这里插入图片描述 在这里插入图片描述

rundone commented 5 months ago

嗨,大家好,我可能已经找到了一些我们可以用来启用滚动条的东西,如果您想更改默认的滚动条可绘制对象,可以在 Android Q 上使用.....无需导入库。

/*Column ScrollBar*/ CellRecyclerView columnRecyclerView = tableView.getColumnHeaderRecyclerView(); columnRecyclerView.setHorizontalScrollBarEnabled(true); columnRecyclerView.setScrollbarFadingEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { columnRecyclerView.setHorizontalScrollbarThumbDrawable(AppCompatResources .getDrawable(context, R.drawable.table_scroll_bar_thumb_drawable)); columnRecyclerView.setHorizontalScrollbarTrackDrawable(AppCompatResources .getDrawable(context, R.drawable.table_scroll_bar_track_drawable)); } columnRecyclerView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); /*Row ScrollBar*/ CellRecyclerView rowRecyclerView = tableView.getRowHeaderRecyclerView(); rowRecyclerView.setVerticalScrollBarEnabled(true); rowRecyclerView.setScrollbarFadingEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { rowRecyclerView.setVerticalScrollbarThumbDrawable(AppCompatResources .getDrawable(context, R.drawable.table_scroll_bar_thumb_drawable)); rowRecyclerView .setVerticalScrollbarTrackDrawable(AppCompatResources.getDrawable(context, R.drawable.table_scroll_bar_track_drawable)); } rowRecyclerView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

好吧,我仍在寻找启用拖动,但尚未找到。如果有人启用了它,请提供帮助,否则我可能需要导入。

Hi guys, I might have found something that we can use to enable scrollbars and if you want to change the default scrollbar drawable it will be possible on Android Q.....without importing Library.

/*Column ScrollBar*/ CellRecyclerView columnRecyclerView = tableView.getColumnHeaderRecyclerView(); columnRecyclerView.setHorizontalScrollBarEnabled(true); columnRecyclerView.setScrollbarFadingEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { columnRecyclerView.setHorizontalScrollbarThumbDrawable(AppCompatResources .getDrawable(context, R.drawable.table_scroll_bar_thumb_drawable)); columnRecyclerView.setHorizontalScrollbarTrackDrawable(AppCompatResources .getDrawable(context, R.drawable.table_scroll_bar_track_drawable)); } columnRecyclerView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); /*Row ScrollBar*/ CellRecyclerView rowRecyclerView = tableView.getRowHeaderRecyclerView(); rowRecyclerView.setVerticalScrollBarEnabled(true); rowRecyclerView.setScrollbarFadingEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { rowRecyclerView.setVerticalScrollbarThumbDrawable(AppCompatResources .getDrawable(context, R.drawable.table_scroll_bar_thumb_drawable)); rowRecyclerView .setVerticalScrollbarTrackDrawable(AppCompatResources.getDrawable(context, R.drawable.table_scroll_bar_track_drawable)); } rowRecyclerView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

Well I am still looking to enable drag but not yet found. Please help if any one got it enabled or else I might need to import.

You can use a third-party library to implement a draggable scrollbar, but cellRecyclerView and rowRecyclerView will not scroll synchronously, so this problem needs to be solved