RecyclerView wrap_content

后端 未结 3 1650
北恋
北恋 2020-12-19 22:23

I am trying to center a RecyclerView when its layout_width is wrap_content without success



        
相关标签:
3条回答
  • 2020-12-19 22:41

    It is related on how the LayoutManager calculates the sizes. Here you have the related bug with some workarounds people have used.

    NOTE: With the release 23.2 of the support library now the wrap content is supported, so looks like they fixed it. You can checkout the changelog here

    0 讨论(0)
  • 2020-12-19 22:41

    Did you try using a RelativeLayout instead of Linear Layout and then make the Recyclerview layout_centerHorizontal="true"

    0 讨论(0)
  • 2020-12-19 22:45

    According to your question, update on (march 2016)

    I suggest you to update to Android Support Library 23.2.1 to support WRAP_CONTENT in RecycleView.

    In RecyclerView layout_width to wrap_content was not supported before 23.2.1.

    solved some issue like Fixed bugs related to various measure-spec methods

    Check http://developer.android.com/tools/support-library/features.html#v7-recyclerview

    0 讨论(0)
提交回复
热议问题