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

An odd human being who happens to have a variety of ever-changing interests, but right now they are programming, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert/drink flavors, obsessing about finding out how some things works, automation, anime, video games... Ran online dessert shops Cookies PH and Catzie's Cakery in her past life.

Leave a Reply

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