避免在recyclerview gridlayoutmanager中滚动第一行和第一列

问题描述 投票:6回答:2

为电视应用创建了双向可滚动gridlayout

从布局文件查看结构

<?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>

所以我使用了gridlayoutmanager(方向垂直),spancount为49(24hrs * 2)+1,用于显示列的图像。第一行是显示分为半小时插槽的时间线,第一列是显示通道,每个通道都有自己的程序在不同的时隙下运行。现在我已经实现了两种方式滚动网格布局,现在我还有两件事要做。

Image of above description

1)当水平滚动时,通道列(第一列)也会滚动并因此被隐藏(它必须垂直滚动,因为可以有20多个通道)。现在我需要使这个列静态wen水平滚动,其他列必须正常滚动

2)当垂直滚动时,时间轴行(第一行)也会滚动并因此被隐藏(它必须水平滚动,因为行必须显示24小时)。现在我需要使这行静态wen垂直滚动,其他行必须正常滚动。

这有可能实现吗?我感谢您的帮助

android android-recyclerview android-tv gridlayoutmanager
2个回答
6
投票

可行的方法是采用三种循环视图

a)频道列表的垂直回收视图

b)时间列表的水平循环视图

c)使用网格布局管理器为数据回收视图

使用网格循环视图的scrollChange侦听器(用于数据的循环视图)

/**
 * 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.
        }
    });
}

如果这种方法适合您,请尝试并告诉我,如果有任何查询,请在下方发表评论,以便我们解决您的问题。


3
投票

试试Github的TableView项目。

TableView是一个功能强大的Android库,用于显示复杂的数据结构并呈现由行,列和单元格组成的表格数据。 TableView依赖于单独的模型对象来保存和表示它显示的数据。此存储库还包含一个示例应用程序,旨在向您展示如何在应用程序中创建自己的TableView。

从该项目中获取概念并修改您想要的内容。

希望这个解释可以帮助你:)

© www.soinside.com 2019 - 2024. All rights reserved.