donald draper
donald draper

Reputation: 571

android - How to make a recycle view like this

I want to make an activity like this , I want to show my latest articles like this ,the big box is the latest article and the other boxes are the latest ones .

enter image description here

how can I make something like this ? is there any library to do so ?

Upvotes: 0

Views: 271

Answers (1)

Nam Trần
Nam Trần

Reputation: 29

        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 is sample can help you

Upvotes: 1

Related Questions