Programmatically scroll to the top of a NestedScrollView

后端 未结 13 1593
情书的邮戳
情书的邮戳 2020-12-13 12:02

Is there a way to programmatically scroll to the top of a NestedScrollView by also triggering the scroll events for the parent? smoothScrollTo(x, y)

相关标签:
13条回答
  • 2020-12-13 12:37

    Here is how I scroll to an item of RecyclerView when RecyclerView is inside NestedScrollView

    First, get an item height then scroll to the position that you want.

    val itemHeight =
        binding.calendarRecyclerView.findViewHolderForAdapterPosition(0)!!.itemView.height
    binding.nestedScrollView2.smoothScrollTo(0, position * itemHeight)
    
    0 讨论(0)
提交回复
热议问题