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

标签 android android-recyclerview android-tv gridlayoutmanager

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

从布局文件中查看结构

<?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 用于图像显示列。 第一行显示时间轴,分为半小时,第一列显示 channel ,每个 channel 将有自己的节目在不同的时间段运行。现在我实现了双向滚动网格布局,现在我还有两件事要做。

Image of above description

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

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

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

最佳答案

可行的方法是使用三个回收 View

a) channel 列表的垂直回收 View

b)定时列表的水平回收 View

c)使用数据的网格布局管理器回收 View

使用 grid recycle view 的 scrollChange 监听器(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.
        }
    });
}

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

关于android - 避免在 recyclerview gridlayoutmanager 中滚动第一行和第一列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47912918/

相关文章:

java - Gigya - Socialize.shortenURL - Android

android - 如何在Android studio中阅读Android Gradle插件源码

java - 删除项目后 Recyclerview 未更新

android - 可以在 Google Play 上为 Android TV 和智能手机发布相同的应用程序

android - 为什么 Android Studio 生成的自适应图标裁剪图像太多以至于无法使用?

java - 安卓/gradle : not able to use repository

android - 如何在代码中选择 ListView 中的第一项(使用 baseadapter)以更改其背景

android - 嵌套的 RecyclerView 不回收

android - RecyclerView onLongClickListener 拒绝触发

android - 如何在主屏幕上设置 Fire TV "icon"?