Unable to detect when the scroll stopped in setOnScrollChangeListener

312 views Asked by At

I want to hide the view when you are scrolling in the webview and show this view when you stop scrolling. How can I detect if you stopped scrolling? I tried to use the following code but doesn't work. I would love to have a hint or an example from you. I want to simple hide & show a certain view according to the users action in the webview.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                            webview.setOnScrollChangeListener { _, _, y, _, oldY ->
                                if (y > oldY || y < oldY) {
                                    val size = Utils.getDisplaySize(requireContext())
                                    val sizeHeight = size.y.toFloat()
                                    bindingMyLayout.boxlayout.apply {
                                        Animation.move(this, 0f, sizeHeight / 4,300
                                        )
                                        Animation.alpha(this, 1f, this.alpha, 300)
                                    }
                                }
                                if (oldY - y == 0) {
                                    Handler().postDelayed({
                                        MyLayout.boxlayout.apply {
                                            visibility = View.VISIBLE
                                            Animation.resetView(this, 200)
                                            Animation.alpha(this, 1f, this.alpha, 200)
                                        }
                                    }, 1000)
                                }

                            }
                        }
0

There are 0 answers