android - 如何制作这样的循环视图

时间:2016-02-10 08:49:53

标签: android android-recyclerview

我想做一个这样的活动,我想展示我的最新文章,大盒子是最新文章,其他盒子是最新的。

enter image description here

我怎么能这样做?有没有图书馆这样做?

1 个答案:

答案 0 :(得分:1)

        final SpannableGridLayoutManager.LayoutParams lp = (SpannableGridLayoutManager.LayoutParams)itemView.getLayoutParams();

        final int span1 = (itemId == 0 || itemId == 3 ? 2 : 1);
        final int span2 = (itemId == 0 ? 2 : (itemId == 3 ? 3 : 1));

        final int colSpan = (isVertical ? span2 : span1);
        final int rowSpan = (isVertical ? span1 : span2);

        if (lp.rowSpan != rowSpan || lp.colSpan != colSpan) {
            lp.rowSpan = rowSpan;
            lp.colSpan = colSpan;
            itemView.setLayoutParams(lp);
        }

https://github.com/lucasr/twoway-view样本可以帮助您