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

Written by

on

in

, ,

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

About the author:

Catzie Avatar

The homo sapiens behind these blog posts is “Catzie“

Explore my top blog posts:

Comments

Leave a Reply

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