【发布时间】: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 小时)。现在我需要使这一行静态垂直滚动,其余行必须正常滚动。
这有可能实现吗?感谢您的帮助
【问题讨论】:
-
是的,我试过了。
-
协调器布局 + 布局行为是您对此类 UI 的解决方案
标签: android android-recyclerview android-tv gridlayoutmanager