Android Horizo​​ntal RecyclerView 滚动方向 [英] Android Horizontal RecyclerView scroll Direction

查看:40
本文介绍了Android Horizo​​ntal RecyclerView 滚动方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个 Horizo​​ntal RecyclerView 并且效果很好(感谢

我的代码:

StaggeredGridLayoutManager staggeredGridLayoutManager =新的交错网格布局管理器(2,//网格中的列数LinearLayoutManager.HORIZONTAL);

解决方案

假设您在 RecyclerView 中使用了 LinearLayoutManager,那么您可以将 true 作为第三个参数传递给 truea 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 Horizo​​ntal RecyclerView 滚动方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆