Avoid scrolling of first row and first column in recyclerview gridlayoutmanager
Asked Answered
M

2

7

Created a two way scrollable gridlayout for a TV app

view structure from layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#021257"
android:orientation="vertical">

<HorizontalScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent">

        <android.support.v7.widget.RecyclerView
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/rvThumbnail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#021257"
            android:orientation="vertical"/>


    </LinearLayout>
</HorizontalScrollView>
</LinearLayout>

so i have used a gridlayoutmanager(orientation vertical) and spancount being 49 (24hrs *2)+1 for images displaying column. The first row is to display timeline divided into half hour slots and first column is to display channels, each channel will have its own programs running under different time slots. Now that i achieved to scroll the gridlayout both ways, now i have two more things to do.

Image of above description

1) When scrolled horizontally, the channels column(first column) also gets scrolled and hence gets hidden(it has to scroll vertically though, since there can be 20+ channels). Now i need to make this column static wen scrolling horizontally and rest other columns must scroll normally

2) When scrolled vertically, the timeline row (first row) also gets scrolled and hence gets hidden(it has to scroll horizontally though, since the row has to display 24 hrs). Now i need to make this row static wen scrolling vertically and rest other rows must scroll normally.

Is this possible to achieve ? I appreciate your help

Mendelsohn answered 20/12, 2017 at 19:13 Comment(3)
Have you tried this https://mcmap.net/q/49781/-is-there-an-addheaderview-equivalent-for-recyclerviewHiroko
Yes I have tried.Mendelsohn
co-ordinator layout + layout behaviors is your solution to this type of UIBittersweet
P
7

The Feasible approach will be to go with three recycle view

a)Vertical recycle view for channel listing

b)Horizontal recycle view for Timing listing

c)Recycle view with grid layout manager for the data

Use scrollChange listener of grid recycle view(Recycle view used for data)

/**
 * Use scroll values
 */
public void setScroll() {
    mDataRecycleView.setOnScrollChangeListener(new View.OnScrollChangeListener() {
        @Override
        public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
          //you can now play on scroll value of this recycle view and    change the scroll value of other recycle views.

   // you can get your view here and also know the value of view so based on value you can handle it here so it's very easy.
        }
    });
}

Try and let me know if this approach works for you and incase any query then comment below so we can solved your problem.

Prudenceprudent answered 27/12, 2017 at 12:37 Comment(1)
I have done this, the target recyclerview scroll misbehavesMendelsohn
S
3

Try TableView project from Github.

TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells. TableView relies on a separate model object to hold and represent the data it displays. This repository also contains a sample app that is designed to show you how to create your own TableView in your application.

Get concept from this project and modify what you want.

Hope this explanation helps you :)

Spiny answered 2/1, 2018 at 14:17 Comment(1)
The question is on television platform, table view is a library for touch based platform look mobile. Where the primary requirement/(library entirely relies) of this library is touch.Mendelsohn

© 2022 - 2024 — McMap. All rights reserved.