A
A
Andrey Myvrenik2016-03-14 10:39:23
Android
Andrey Myvrenik, 2016-03-14 10:39:23

How to make first item in RecyclerView+StaggeredGridLayoutManager full screen width?

There is a RecyclerView with a StaggeredGridLayoutManager connected to it to display items in two columns. How to achieve that the first element is always on top and takes up all the space horizontally?
9a9e48111b844838b57429b533b50ee9.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tiberal, 2016-03-14
@gim0

private View createLayoutParams(View targetView) {
        StaggeredGridLayoutManager.LayoutParams params;
        params = new StaggeredGridLayoutManager.LayoutParams(StaggeredGridLayoutManager.LayoutParams.MATCH_PARENT, StaggeredGridLayoutManager.LayoutParams.WRAP_CONTENT);
        params.setFullSpan(true);
        targetView.setLayoutParams(params);
        return targetView;
    }

in the method throw a view that needs to be stretched to full screen

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question