How to expand space between recyclerview
item while scrolling as shown below. I tried to add a custom animation in onBindViewHolder
method but this solution doesn't work as I want. It looks like some animation add to RecyclerView.OnScrollListener.onScrolled
method. Any idea? Thx.
Asked
Active
Viewed 1,094 times
11
-
did you get the solution? I also wanted to implement the same. – Riddhi Shah Sep 10 '18 at 05:56
-
no, I didn't :( – kazhiu Sep 24 '18 at 12:05
-
If you have any idea then, please share it. – Riddhi Shah Sep 24 '18 at 13:06
-
ok no problem, I will be remember – kazhiu Sep 24 '18 at 13:12
1 Answers
0
One thing we can do is hiding and showing a transparent view below ItemLayout onSrcoll
var scrollListener = object : OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
(list.adapter as CustomAdapter).changeState(newState)
}
}
and in Adapter
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
if(state == RecyclerView.SCROLL_STATE_IDLE){
holder.view.visibility = View.GONE
}else{
holder.view.visibility = View.VISIBLE
}
}
fun changeState(newState: Int) {
state = newState
notifyDataSetChanged()
}

kelvin
- 1,480
- 1
- 14
- 28