timusus / RecyclerView-FastScroll

A simple FastScroller for Android's RecyclerView
Other
1.39k stars 183 forks source link

Change thumb color when scrolled #78

Closed feliperce closed 6 years ago

feliperce commented 6 years ago

How to change fastScrollThumbColor when scrolled, I tried to set:

override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) {
                when (newState) {
                    RecyclerView.SCROLL_STATE_IDLE ->
                        categoryFilterRecyclerView.setThumbColor(Color.DKGRAY)
                    RecyclerView.SCROLL_STATE_DRAGGING ->
                        categoryFilterRecyclerView.setThumbColor(ResourcesCompat.getColor(
                                resources, R.color.colorPrimaryDark, null))
                    RecyclerView.SCROLL_STATE_SETTLING->
                        categoryFilterRecyclerView.setThumbColor(ResourcesCompat.getColor(
                                resources, R.color.colorPrimaryDark, null))

                }

            }
        })

It changes when scrolled, but not change when FAST scrolled

timusus commented 6 years ago

You can attach an OnFastScrollStateChangedListener to the FastScrollRecyclerView.

Alternatively, fork this library and find the code that detects when the fast scroll is touched, and change the colour there.