0

I'm using a RecyclerView with GridLayoutManager, but as I have to specify how many columns I will be using, it divides all the columns width equally, and therefore, my RecyclerView messes up as on the picture below.

.

As you can see, every item has a fixed width and not a wrap_content as I expected.

1 Answer 1

2

I assume you want each chip to have enough width to wrap its content, and you do not want every chip in a given column to have the same width.

If so, you probably do not want to use GridLayoutManager. Essentially no matter what you do, it will still wind up defining some fixed column width (though you can set it up so that different columns have different widths). I believe a better choice would be FlexboxLayoutManager.

FlexboxLayout is a library from Google that allows you to specify a set of items and have them lay themselves out, wrapping as necessary. Find details here: https://github.com/google/flexbox-layout

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.