简体   繁体   English

VerticalGridView水平滚动

[英]VerticalGridView scrolls horizontally

I finally had success adding a VerticalGridView from android support library to my project. 我终于成功地将android支持库中的VerticalGridView添加到我的项目中。 Now the problem is the grid scrolls both horizontally and vertically! 现在问题是网格水平和垂直滚动!

Here is my source : 这是我的来源:

<android.support.v17.leanback.widget.VerticalGridView
            android:id="@+id/my_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical" />

and java code: 和java代码:

mRecyclerView = (VerticalGridView) rootView.findViewById(R.id.my_recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setNumColumns(4);
mRecyclerView.setVerticalMargin(24);

I have found a fix this. 我找到了解决方法。 You just have to set android.support.v7.widget.GridLayoutManager as the layout manager for the VerticalGridView , as in the following (notice that the number of columns is passed in the constructor): 您只需将android.support.v7.widget.GridLayoutManager设置为VerticalGridView的布局管理器,如下所示(请注意在构造函数中传递的列数):

mRecyclerView = (VerticalGridView) rootView.findViewById(R.id.my_recycler_view);
mRecyclerView.setLayoutManager(new GridLayoutManager(context, 4));
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setVerticalMargin(24);

在leanback lib中有两个类是1. VerticalGridView 2.Horizo​​ntalGridView你可以使用Horizo​​ntalGridView进行水平滚动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 回收者视图将项目排列在水平滚动的网格中 - Recycler view arrange items in a grid that scrolls horizontally 垂直方向的 Recyclerview 在屏幕的水平滚动上上下滚动 - Recyclerview with vertical orientation scrolls up and down on horizontally scrolls of the Screen 如何在Android中创建水平和垂直滚动的列表视图? - How can I create a listview that scrolls both horizontally and vertically in Android? Android:Onclick在VerticalGridView中不起作用 - Android: Onclick not working in VerticalGridView VerticalGridView 中的重复卡片 - Duplicated cards in verticalGridView Leanback 的 VerticalGridView 中的不同视图类型 - Different viewtype in Leanback's VerticalGridView 当用户水平滚动时,div的背景色不会超出初始视图 - Background-color of div does not display beyond initial view when user scrolls horizontally TextView和VerticalGridView之间的上下焦点处理 - UP DOWN Focus Handling between TextView and VerticalGridView 通过将焦点保持在中心元素上滚动 VerticalGridView 或 RecyclerView - Scroll the VerticalGridView or RecyclerView by keeping focus on center element 如何将 SpanSizeLookup 逻辑添加到 VerticalGridView? - How can I add SpanSizeLookup logic to VerticalGridView?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM