简体   繁体   English

Recycler View向两个方向滚动

[英]Recycler View scrolling in both direction

RecyclerView with vertical scrolling working fine. RecyclerView与垂直滚动工作正常。 now i want that item of RecycelerView should be also scroll in horizontal direction in android. 现在我想要RecycelerView的项目也应该在android中水平方向滚动。 how is it possible? 这怎么可能?

LinearLayoutManager layoutManager = ...
recyclerView.setLayoutManager(layoutManager);

when you want horizontal 当你想要水平

layoutManager.setOrientation(context,LinearLayoutManager.HORIZONTAL,false);

when you want vertical 当你想要垂直

layoutManager.setOrientation(context,LinearLayoutManager.VERTICAL,false);

You can set the LinearLayoutManager to Horizontal orientation .. Try like this 您可以将LinearLayoutManager设置为Horizontal方向。尝试这样

recyclerView.setLayoutManager(
          new LinearLayoutManager(Activity.this, LinearLayoutManager.HORIZONTAL, false));

Hope this helps 希望这可以帮助

EDIT 编辑

Try this 试试这个

There is FixedGridLayoutManager Which is scrollable in bothways. 两个可滚动的FixedGridLayoutManager。 And also refer this 并且也参考这个

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM