DJp*_*phy 6 android android-tv gridlayoutmanager android-recyclerview
为电视应用创建了双向可滚动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>
Run Code Online (Sandbox Code Playgroud)
所以我使用了gridlayoutmanager(方向垂直),spancount为49(24hrs*2)+1,用于显示列的图像.的第一行是显示时间轴分成半小时时隙,第一列是显示信道,每个信道将具有下不同时隙运行其自己的程序.现在我已经实现了两种方式滚动网格布局,现在我还有两件事要做.
1)当水平滚动时,通道列(第一列)也会滚动并因此被隐藏(它必须垂直滚动,因为可以有20多个通道).现在我需要使这个列静态wen水平滚动,其他列必须正常滚动
2)当垂直滚动时,时间轴行(第一行)也会滚动并因此被隐藏(它必须水平滚动,因为行必须显示24小时).现在我需要使这行静态wen垂直滚动,其他行必须正常滚动.
这有可能实现吗?我感谢您的帮助
小智 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.
}
});
}
Run Code Online (Sandbox Code Playgroud)
请尝试并告诉我这种方法是否适合您,并在任何查询后面进行评论,以便我们解决您的问题.
| 归档时间: |
|
| 查看次数: |
865 次 |
| 最近记录: |