Avoid scrolling the first row and first column in recyclerview gridlayoutmanager

Created a two-way scrollable gridlayout for a television application

layout 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 used the gridlayoutmanager (orientation vertical) and spancount equal to 49 (24 hours * 2) +1 for images displaying columns. the first line displays the timeline , divided by half an hour, and the first column displays the channels , each channel will have its own programs running under different time intervals. Now that I have reached the gridlayout scroll in both directions, now I have two more things.

Image above description

1) When scrolling horizontally, the channel column (the first column) also scrolls and, therefore, is hidden (it should scroll vertically, although there may be 20 + channels). Now I need to make this column stationary by scrolling horizontally, and the rest of the remaining columns should scroll normally

2) . When scrolling vertically, the timeline line (first line) also scrolls and therefore hides (it should scroll horizontally, since the line should be displayed for 24 hours). Now I need to make this static wen line scroll vertically and the rest of the lines should scroll normally.

Can this be achieved? I appreciate your help.

+5
source share
2 answers

A reasonable approach is to go with three types of processing

a) Vertical view to list channels

b) Horizontal view for time list

c) Backup with data layout manager for data

Use scrollChange grid view listener (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 very easy. } }); } 

Try it and let me know if this approach works for you, and run any request, and then comment below so that we can solve your problem.

+6
source

Try the TableView project from Github.

TableView is a powerful Android library for displaying complex structure data and displaying tabular data consisting of rows, columns and cells. TableView relies on a separate model object for storage and represents the displayed data. This repository also contains a sample application designed to show you how to create your own TableView in your application.

Get the concept from this project and change what you want.

Hope this explanation helps you :)

+2
source

Source: https://habr.com/ru/post/1274232/


All Articles