Skip to main content
added 313 characters in body
Source Link
HongSec Park
  • 1.2k
  • 1
  • 9
  • 9
 private val delayShowRunnable by lazy{ object:Runnable{ override fun run() { rv_content?.alpha=1f  } } } private val linearSmoothScroller by lazy{ object: LinearSmoothScroller(context){ override fun onTargetFound(targetView: View, state: RecyclerView.State, action: Action) {  super.onTargetFound(targetView, state, action)  rv_content?.postDelayed(delayShowRunnable,50)   }  override fun calculateTimeForDeceleration(dx: Int): Int { return 1//set max speed } override fun calculateTimeForScrolling(dx: Int): Int { return 1 //set max speed } } } rv_content?.alpha=0f //hide listview before scroll finish rv_content?.postDelayed({  rv_content?.alpha=1f //delay show listview    },500) linearSmoothScroller.targetPosition = postpos (rv_content?.layoutManager as LinearLayoutManager?)?.startSmoothScroll(linearSmoothScroller) 

scroll position change will not be reflected until the next layout call. so we should use <smoothscrollToPosition()> , find out target view.

 private val linearSmoothScroller by lazy{ object: LinearSmoothScroller(context){ override fun calculateTimeForDeceleration(dx: Int): Int { return 1//set max speed } override fun calculateTimeForScrolling(dx: Int): Int { return 1 //set max speed } } } rv_content?.alpha=0f //hide listview before scroll finish rv_content?.postDelayed({  rv_content?.alpha=1f //delay show listview    },500) linearSmoothScroller.targetPosition = post (rv_content?.layoutManager as LinearLayoutManager?)?.startSmoothScroll(linearSmoothScroller) 

scroll position change will not be reflected until the next layout call. so we should use <smoothscrollToPosition()> , find out target view.

 private val delayShowRunnable by lazy{ object:Runnable{ override fun run() { rv_content?.alpha=1f  } } } private val linearSmoothScroller by lazy{ object: LinearSmoothScroller(context){ override fun onTargetFound(targetView: View, state: RecyclerView.State, action: Action) {  super.onTargetFound(targetView, state, action)  rv_content?.postDelayed(delayShowRunnable,50)   }  override fun calculateTimeForDeceleration(dx: Int): Int { return 1//set max speed } override fun calculateTimeForScrolling(dx: Int): Int { return 1 //set max speed } } } rv_content?.alpha=0f //hide listview before scroll finish linearSmoothScroller.targetPosition = pos (rv_content?.layoutManager as LinearLayoutManager?)?.startSmoothScroll(linearSmoothScroller) 

scroll position change will not be reflected until the next layout call. so we should use <smoothscrollToPosition()> , find out target view.

Source Link
HongSec Park
  • 1.2k
  • 1
  • 9
  • 9

 private val linearSmoothScroller by lazy{ object: LinearSmoothScroller(context){ override fun calculateTimeForDeceleration(dx: Int): Int { return 1//set max speed } override fun calculateTimeForScrolling(dx: Int): Int { return 1 //set max speed } } } rv_content?.alpha=0f //hide listview before scroll finish rv_content?.postDelayed({ rv_content?.alpha=1f //delay show listview },500) linearSmoothScroller.targetPosition = post (rv_content?.layoutManager as LinearLayoutManager?)?.startSmoothScroll(linearSmoothScroller) 

scroll position change will not be reflected until the next layout call. so we should use <smoothscrollToPosition()> , find out target view.