0

I have this structure

RecyclerView
 - ConstraintLayout
 - - CardView
 - - - ConstraintLayout
 - - - - ImageView 
 - - - - TextView
 - - - - TextView

Code:

    vm = ViewModelProvider(this)[CatalogViewModel::class.java]
    vm.getList().observe(this, Observer {
        dataView = findViewById(R.id.dataList)
        adapter = CatalogRecycleViewAdapter(this, it.data.data)

        dataView.layoutManager = GridLayoutManager(this, 2, GridLayoutManager.VERTICAL, false);
        dataView.adapter = adapter;
    })

And if I have 2 or more items width different height, there's an empty space in a column.

If I have 2 or more items width different height there's an empty space in a column

How to remove it and make something like in picture?

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

2

It seems like your TextView has wrap_content height, thats the reason one is bigger. Checkout this answer to get the result you are looking for StaggeredGridLayoutManager

Gorks
  • 120
  • 9