Reputation: 41
I want to create a two columns listView with items of varying heights like that: image
I have try this custom class found on GitHub and it was perfect but I have different problems because maybe the class is old (last update: 2014):
[Edit] Solution:
Proposed by Piyush: StaggeredGridLayoutManager with RecyclerView
Upvotes: 3
Views: 84
Reputation: 69689
you can use StaggeredGridLayoutManager
you can use StaggeredGridLayoutManager
private StaggeredGridLayoutManager gaggeredGridLayoutManager;
gaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, 1);
recyclerView.setLayoutManager(gaggeredGridLayoutManager);
for more information follow this link StaggeredGridLayoutManager
Upvotes: 2
Reputation: 1337
Why don't you use a ScrollView instead? So you'll have a parent ScrollView containing just one RelativeLayout. Then you'll place two vertical LinearLayout inside the Relative one in which you are going to place your varying heights cells. Pseudo-code follows:
<ScrollView>
<RelativeLayout>
<LinearLayout orientation="vertical">
//insert you items here via GroupView.addView inside your activity
</LinearLayout>
<LinearLayout orientation="vertical">
</LinearLayout>
</RelativeLayout>
<ScrollView>
Upvotes: 0