Make a RecyclerView expand its height when new item is added //Android Dev Diary

It seems that simply using android:layout_height="wrap_content" on your RecyclerView won’t make its height automatically expand when new items are added in it.

I also tried using recyclerView.setHasFixedSize(false) in my Kotlin fragment file, but that didn’t help at all. (But try it, maybe our issues are different. The parent of my RecyclerView is a ConstraintLayout.)

What helped was wrapping my RecyclerView (whose height is match_parent) inside a RelativeLayout (whose height is wrap_content)

Old Code:

New Code:

Related Posts:

Posts that may be related to "Make a RecyclerView expand its height when new item is added //Android Dev Diary":

Catzie

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

Your email address will not be published. Required fields are marked *