【问题标题】:Avoid scrolling of first row and first column in recyclerview gridlayoutmanager避免在recyclerview gridlayoutmanager中滚动第一行和第一列
【发布时间】:2018-06-03 10:04:50
【问题描述】:

为电视应用创建双向可滚动网格布局

布局文件中的视图结构

<?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(orientation vertical) 和 spancount 为 49 (24hrs *2)+1 的图像显示列。 第一行是显示时间线分为半小时时段,第一列是显示频道,每个频道将有自己的程序在不同的时间段运行。现在我已经实现了双向滚动网格布局,现在我还有两件事要做。

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

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

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

【问题讨论】:

标签: android android-recyclerview android-tv gridlayoutmanager


【解决方案1】:

尝试来自 Github 的 TableView 项目。

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

从这个项目中获取概念并修改你想要的。

希望这个解释对你有帮助:)

【讨论】:

  • 问题是在电视平台上,table view 是一个基于触摸的平台look mobile 的库。这个库的主要需求/(库完全依赖)是触摸的。
【解决方案2】:

可行的方法是采用三个回收视图

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

尝试让我知道这种方法是否适合您,如果有任何疑问,请在下方发表评论,以便我们解决您的问题。

【讨论】:

  • 我已经这样做了,目标recyclerview滚动行为异常
猜你喜欢
  • 1970-01-01
  • 2021-08-14
  • 2019-12-17
  • 1970-01-01
  • 1970-01-01
  • 2020-07-24
  • 2021-05-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多