停止用户滚动到RecyclerView设置位置 [英] Stop user scroll to set position on RecyclerView
问题描述
所以我有一个问题,我是很新的机器人编程,它已经只有6-8个星期,因为我已经开始编程的Android应用程序,所以我可能是盲目的,而不是见容易的答案,但这里是我的问题
so i've got a problem, i'm quite new to android programming, it's been only 6-8 weeks since i've started programming android apps so i may be blind and not see the easy answer but here's my problem:
我在做一个学校项目,我试图建立一个类似日历一个在今天的经济日历拆分视图(唯一的下方位置)
I'm making a school project and i'm trying to develop a similar calendar to the one in Today's Calendar split view (The one below here)
http://i.imgur.com/Twhpauo.png
所以我做了一个GridLayoutManager看起来像这样一个RecyclerView:
So i've made a RecyclerView with a GridLayoutManager that looks like this:
http://i.imgur.com/LyxoCzk.png
和,直到在这里一切都很好,但我想要实现,设置今天的日期的日历按钮,事情是,当我滚动了一扔,然后设置RecyclerView立场scrollToPositionWithOffset(位置, 0);视图保持从第一一扔上涨的势头,设置位置,然后不断滚动,直到动能消失
And up until here everything's fine, but i'm trying to implement the button that sets the calendar on today's date, the thing is that when i'm scrolling with a fling and then set the RecyclerView position with scrollToPositionWithOffset(position, 0); the view keeps the momentum gained from the first fling, sets the position and then keeps on scrolling until the momentum is gone
我已经搜查了很多,以找到一个解决方案,当我使用的GridView,而不是RecyclerView我用smoothScrollToPositionFromTop(),它停止滚动,然后setSelection()来定位,但在GridView跳过的帧,我不得不变化,这里RecyclerView没有smoothScrollToPositionFromTop和smoothScrollToPosition不停止滚动,同样没有scrollToPosition或scrollToPositionWithOffset。
I've searched a lot to find a solution, when i was using gridView instead of RecyclerView i used smoothScrollToPositionFromTop() which stopped the scrolling and then the setSelection() to position it, but the gridView skipped frames and i had to change, here with RecyclerView there is no smoothScrollToPositionFromTop and smoothScrollToPosition doesn't stop the scroll, neither does scrollToPosition or scrollToPositionWithOffset.
发现这个,但不利于<一href="https://stackoverflow.com/questions/26875061/scroll-recyclerview-to-show-selected-item-on-top">Scroll RecyclerView显示选择项目上面
和其他许多人没有帮助。
and many others that didn't help.
我认为实现我自己的滚动逻辑,但是,当我看着它,我的头爆炸了,我不知道从哪里开始。
I considered implementing my own scrolling logic but when i looked into it my head exploded and i wouldn't know where to begin.
有谁知道如何解决这个问题?
Does anyone know how to solve this?
推荐答案
你知道吗? RecyclerView
有一个 stopScroll()
方法停止滚动的进展如何?
Did you know that RecyclerView
has a stopScroll()
method to stop a scroll in progress?
这篇关于停止用户滚动到RecyclerView设置位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!