Android Horizontal RecyclerView滚动方向 [英] Android Horizontal RecyclerView scroll Direction
问题描述
我制作了卧式RecyclerView,它可以正常工作(感谢此),但滚动和数据的方向从左向右扩展;那么如何更改RecyclerView的滚动方向,如下图所示?
I made a Horizontal RecyclerView and it works fine(thanks to this) but the direction of scroll and data are expand from left to right; then How can I change the RecyclerView scroll direction like in the picture below?
我的代码:
StaggeredGridLayoutManager staggeredGridLayoutManager =
new StaggeredGridLayoutManager(
2, //The number of Columns in the grid
LinearLayoutManager.HORIZONTAL);
推荐答案
假设您在RecyclerView中使用LinearLayoutManager
,则可以将true
作为第三个参数传递给
Assuming you use LinearLayoutManager
in your RecyclerView, then you can pass true
as third argument in the LinearLayoutManager constructor.
例如:
mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true));
如果使用的是StaggeredGridLayoutManager
,则可以使用它提供的setReverseLayout
方法.
If you are using the StaggeredGridLayoutManager
, then you can use the setReverseLayout
method it provides.
这篇关于Android Horizontal RecyclerView滚动方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!