I have a recyclerview with 2 or more viewholders,
- 1st Viewholder is just top heading banner
- 2nd vlewholder is for booking widget which has 3 dropdowns/detail menus including
CalendarView
-- All in one viewhodler.
Issue is CalendarView is quite big in height and when the CalendarView is slightly off the screen and I collapse/gone the calendar it is collapsing but still taking space just like below screenshots. But Strange thing is that its occurring only in Android 8 & 9
.
Initial Screenshot:
Issue Screenshot (After Collapsing CV):
Relevant Code is below:
Viewholder Item's ClickListener:
val clickListener = View.OnClickListener {
// irrelevant code //
for (type in AllOptionsEnum.values()) {
// Expand Selected and Collapse Others
val detailView = this.root.findViewById<ViewGroup>(type.detailViewGroupId)
val labelView = this.root.findViewById<TextView>(type.labelViewId)
val checkBox = this.root.findViewById<CheckBox>(type.checkBoxId)
if (detailView.visibility == View.VISIBLE) {
// hide detailed view
detailView.setVisible(show = false)
checkBox.isChecked = false
} else {
// show
detailView.setVisible(show = (type.labelViewGroupId == it.id))
checkBox.isChecked = show = (type.labelViewGroupId == it.id)
}
// irrelevant code //
}
}
Edit 1: Extension Func:
fun View.setVisible(show: Boolean = true, invisible: Boolean = false) {
if (show) this.visibility = View.VISIBLE
else this.visibility = if (invisible) View.INVISIBLE else View.GONE
}
Edit 2:
I have tried another solution i.e. to remove the recyclerview completely and re-constructed the whole screen using nestedscrollview but it also has same effects.
Edit 3:
I have tried below code also but same result
// show detailView
if(type==Enums.StayWithUsWidgetType.TYPE_CALENDAR){
// show detailview and children
this.calendarDetailView.children.forEach {
it.visible()
}
}
// Hide detailView and children
if(type==Enums.StayWithUsWidgetType.TYPE_CALENDAR){
// hide all
this.calendarDetailView.children.forEach {
it.gone()
}
}