Two ListView columns with items of different heights

I want to create a list of two columns with elements of different heights: image

I tried this custom class found on GitHub and it was fine, but I have different problems because maybe the class is old (last update: 2014):

  • Child images with onClickListener block scrolling of custom listView
  • SwipeRefreshLayout always appears when scrolling up (I only want it when I'm at the top of the list)

[Edit] Solution:

Proposed by Piyush: StaggeredGridLayoutManager with RecyclerView

+3


source to share


2 answers


you can use StaggeredGridLayoutManager

you can use StaggeredGridLayoutManager

private StaggeredGridLayoutManager gaggeredGridLayoutManager;
gaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, 1);
recyclerView.setLayoutManager(gaggeredGridLayoutManager);

      



for more info visit this link StaggeredGridLayoutManager

enter image description here

+2


source


Why aren't you using ScrollView instead? This way you will have a parent ScrollView containing only one RelativeLayout. Then you will place two vertical LinearLayouts inside the Relative where you intend to place your cells with varying heights. Below is the pseudocode:



<ScrollView>
  <RelativeLayout>
       <LinearLayout orientation="vertical">
         //insert you items here via GroupView.addView inside your activity
       </LinearLayout>
       <LinearLayout orientation="vertical">
       </LinearLayout>
  </RelativeLayout>
<ScrollView>

      

0


source







All Articles