0

I have ConstraintLayout with WRAP_CONTENT height, in which i show/hide RecyclerView (or another ConstraintLayout) by changing it's height from 0 (MATCH_CONSTRAINT) to WRAP_CONTENT and back.

It works perfectly, but only on Android 8.0 and higher. When I tested it on Android 7.1.2 and 6.0, RecyclerView height is changed fully, but ConstraintLayout changes size only a little bit, showing empty space in the place of RecyclerView

private fun onModelClick(view: View?) {
    val layoutParams = modelRecyclerView.layoutParams as ConstraintLayout.LayoutParams
    if (isModelVisible)
        layoutParams.height = 0
    else
        layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT
    modelRecyclerView.layoutParams = layoutParams
    isModelVisible = !isModelVisible
}
kanphis
  • 1
  • 2

1 Answers1

0

https://github.com/material-components/material-components-android/issues/537

Seems it's bug of MaterialCardView, in which ConstraintLayout was stored. Changing to old CardView or upgrading to 1.2.0-alpha06 fixes the problem

kanphis
  • 1
  • 2