Calendar View show/gone inside Recyclerview ViewHolder Issue on Android 8, 9 only
Asked Answered
S

1

8

I have a recyclerview with 2 or more viewholders,

  1. 1st Viewholder is just top heading banner
  2. 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:

enter image description here

Issue Screenshot (After Collapsing CV):

enter image description here

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()
                    }
                }
Sendoff answered 27/7, 2023 at 21:11 Comment(0)
R
0

You can try with setting the Calenderview height programatically like below that can help you in showing extra space of that view.


if(type==Enums.StayWithUsWidgetType.TYPE_CALENDAR){
                    // setup height when needed
                    this.calendarDetailView.children.forEach {
                        calendarDetailView.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
                    }
                }

Roadwork answered 5/8, 2023 at 6:37 Comment(1)
not working :(.Sendoff

© 2022 - 2024 — McMap. All rights reserved.