如何使Recycler View开始从中心添加项目? [英] How to make recycler view start adding items from center?

查看:82
本文介绍了如何使Recycler View开始从中心添加项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我有一个带有水平线性布局"的recyclerView作为布局管理器.
  • 回收站视图处于框架布局中,layout_gravity ="center",而layout_width ="wrap_content"
  • 我希望回收者视图开始从中心添加项目.
  • 这就是我想要的:

  • 这就是我得到的:

  • 您可以看到,在最后一个图像中,项目是从左侧添加的.我希望它从中心添加项目,如前三个图像所示.

推荐答案

我遇到了同样的问题,并针对我的水平RecyclerView像这样解决了这个问题:

i had same issue and solved like this for my horizontal RecyclerView:

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="wrap_content"
        android:layout_height="68dp"
        android:layout_centerHorizontal="true"
        android:orientation="horizontal"
        app:layoutManager="android.support.v7.widget.LinearLayoutManager" />

此处主要部分是android:layout_centerHorizo​​ntal ="true"和layout_width ="wrap_content"

这篇关于如何使Recycler View开始从中心添加项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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