【问题标题】:Horizontal RecyclerView - list items arranged from center [duplicate]Horizo​​ntal RecyclerView - 从中​​心排列的列表项目[重复]
【发布时间】:2018-08-14 09:12:29
【问题描述】:

有没有办法显示居中对齐的水平回收视图的项目。 即列表的重心将是 center_horizo​​ntal。

例如,要实现这样的事情:

【问题讨论】:

  • 为什么不使用layout_gravity=center 来作为Horizo​​ntal Recycler 视图本身?
  • @Khamraj 嗨,我的想法是填充宽度,但我想这也应该可行。

标签: android android-layout listview android-recyclerview


【解决方案1】:

您可以定义您的自定义布局管理器: Android Centering Item in RecyclerView

或者,如果您需要离散滚动,这里是 lib: https://android-arsenal.com/details/1/5480

或者 recyclerView 可以是 wrap_content 在父框架中居中对齐: How do I make WRAP_CONTENT work on a RecyclerView

【讨论】:

    【解决方案2】:

    试试这个代码:

    SnapHelper helper = new LinearSnapHelper();
    helper.attachToRecyclerView(recyclerView);
    

    【讨论】:

      猜你喜欢
      • 2019-03-30
      • 1970-01-01
      • 1970-01-01
      • 2018-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-29
      相关资源
      最近更新 更多