循环系统嵌套在线层中以及滚动浏览不滚动到特定的回收项目位置
我下面的代码不适合每个特定的卷轴或SmootyScrollto,谁能帮助我? 我基本上希望能够动态滚动到活动中的特定项目位置,例如,如果已单击特定的RecyClerviewItem,则将转到活动并滚动到特定项目。该位置变量的范围从“ recyclerview.getChildAdapterPosition(itemView)”到itemView.bottom,bottom也不起作用。 帮助您将不胜感激。
private fun focusOnView(scroll: ScrollView, itemView : View?,position :Int) {
scroll.post(Runnable {
if (editBox != null) {
val x= 1
// scroll.scrollTo(0,NestedScrollView.FOCUS_DOWN)
// scroll.smoothScrollTo(0, scroll.bottom)
scroll.smoothScrollTo(0,position)
//scroll.fullScroll(130)
}
})
}
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/contentreyclerpager"
android:layout_width="match_parent"
android:paddingTop="10dp"
android:layout_height="wrap_content" />
</RelativeLayout>
</ScrollView>
My code below doesnt work for each specific scrollto or smoothScrollTo, can anyone help me?
I basically want to be able to dynamically scroll to a specific Item position in the activity, e.g. if a specific recyclerviewItem has been clicked on it will go to the activity and scroll to the specific item. The position variable has been ranging from "recyclerview.getChildAdapterPosition(itemview)" to itemview.Bottom which also doesn't work.
Help would be appreciated.
private fun focusOnView(scroll: ScrollView, itemView : View?,position :Int) {
scroll.post(Runnable {
if (editBox != null) {
val x= 1
// scroll.scrollTo(0,NestedScrollView.FOCUS_DOWN)
// scroll.smoothScrollTo(0, scroll.bottom)
scroll.smoothScrollTo(0,position)
//scroll.fullScroll(130)
}
})
}
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/contentreyclerpager"
android:layout_width="match_parent"
android:paddingTop="10dp"
android:layout_height="wrap_content" />
</RelativeLayout>
</ScrollView>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么您使用nestedscollview SmoothScrollto以及必须给出X,y坐标的位置,我认为在您的情况下,您可以使用recycleView.smoothscrolltoposition(your position);
Why you use the nestedScollView smoothScrollTo with the position you have to give x,y coordonate i think in your case you can use recycleView.smoothScrollToPosition(yourPosition);