RecyclerView wrap_content with GridLayoutManager
Asked Answered
B

2

6

I've seen workarounds with LinearLayoutManager, but not with GridLayoutManager. Any ideas?

Bout answered 9/6, 2015 at 18:40 Comment(2)
Can you ellaborate? What exactly is the issue?Auroora
@TheoK RecyclerView ignores the attribute wrap_content and assumes that it's height is 0. The issue is mentioned here. There is a solution for LinearLayoutManager but not for GridLayoutManager.Bout
B
-4

I've solved the problem by using only one RecyclerView and using getItemViewType(int position) method in the adapter. Example here.

Bout answered 19/6, 2015 at 8:25 Comment(0)
H
6

According to the announce of a support library version 23.2.0 all default layout managers support auto-measurement now. So all WRAP_CONTENT and MATCH_PARENT should work correctly from this moment.

Don't forget to update version of a library in gradle file.

compile 'com.android.support:recyclerview-v7:23.2.0'
Hitchhike answered 25/2, 2016 at 9:15 Comment(0)
B
-4

I've solved the problem by using only one RecyclerView and using getItemViewType(int position) method in the adapter. Example here.

Bout answered 19/6, 2015 at 8:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.