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
}