2017-06-19 74 views
3

的项目的ListView我想创建一个两列的ListView用不同高度的物品,如认为: image两列不同高度

我试试这个custom class在GitHub上找到,这是完美的,但我有不同的问题因为也许类是旧的(最后更新日期:2014):

  • 子项与onClickListener图像块自定义ListView的滚动
  • SwipeRefreshLayout似乎总是在滚动起来(我只希望当我在的顶部列表)

[编辑]解决方案:

通过的Piyush建议: StaggeredGridLayoutManager with RecyclerView

+0

到目前为止您尝试过的是什么? –

+0

你可以使用StaggeredGridLayoutManager和RecyclerView:https://android--code.blogspot.in/2015/12/android-recyclerview.html – Piyush

+0

谢谢你Piyush的解决方案!有用 !!! :D – tmagnier

回答

2

可以使用StaggeredGridLayoutManager

可以使用StaggeredGridLayoutManager

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

更多信息,请点击此链接StaggeredGridLayoutManager

enter image description here

0

你为什么不使用滚动型呢?所以你将有一个包含一个RelativeLayout的父ScrollView。然后,您将在相对的一个中放置两个垂直的LinearLayout,您将在其中放置不同高度的单元格。 伪代码如下:

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

我不确定您的解决方案是否已优化,但感谢您的帮助! – tmagnier