tmagnier
tmagnier

Reputation: 41

Two columns ListView with items of varying heights

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

Answers (2)

AskNilesh
AskNilesh

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

enter image description here

Upvotes: 2

Stack Diego
Stack Diego

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

Related Questions