Android Horizontal RecyclerView 滚动方向 [英] Android Horizontal RecyclerView scroll Direction
问题描述
我制作了一个 Horizontal RecyclerView 并且效果很好(感谢
我的代码:
StaggeredGridLayoutManager staggeredGridLayoutManager =新的交错网格布局管理器(2,//网格中的列数LinearLayoutManager.HORIZONTAL);
假设您在 RecyclerView 中使用了 LinearLayoutManager
,那么您可以将 true
作为第三个参数传递给 true
a href="https://developer.android.com/reference/android/support/v7/widget/LinearLayoutManager.html#LinearLayoutManager(android.content.Context,%20int,%20boolean)" rel="noreferrer">LinearLayoutManager 构造函数.
例如:
mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true));
如果您使用的是 StaggeredGridLayoutManager
,那么您可以使用它提供的 setReverseLayout
方法.
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?
My Code:
StaggeredGridLayoutManager staggeredGridLayoutManager =
new StaggeredGridLayoutManager(
2, //The number of Columns in the grid
LinearLayoutManager.HORIZONTAL);
Assuming you use LinearLayoutManager
in your RecyclerView, then you can pass true
as third argument in the LinearLayoutManager constructor.
For example:
mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, true));
If you are using the StaggeredGridLayoutManager
, then you can use the setReverseLayout
method it provides.
这篇关于Android Horizontal RecyclerView 滚动方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!