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

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

问题描述

我制作了卧式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 Horizo​​ntal RecyclerView滚动方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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