循环系统嵌套在线层中以及滚动浏览不滚动到特定的回收项目位置

发布于 2025-02-06 07:53:22 字数 1366 浏览 2 评论 0原文

我下面的代码不适合每个特定的卷轴或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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

开始看清了 2025-02-13 07:53:22

为什么您使用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);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文