草庐IT

RecyclerVIew

全部标签

android - 如何使用垂直 GridLayoutManager 水平居中 RecyclerView 项目

我有一个使用GridLayoutManager的垂直RecyclerView。我希望每列居中,但列从左侧开始。在下面的图片中,您可以看到我在说什么。我使用丑陋的配色方案来说明列和背景。绿色是RecyclerView中每一项的背景,红色是RecyclerView本身的背景:http://imgur.com/a/J3HtF我正在设置它:mRecyclerView.setLayoutManager(newGridLayoutManager(this,2));这是column_item.xml:这是recyclerviewxml: 最佳答案

android - (Smooth)ScrollToPosition 不能与 RecyclerView 一起正常工作

我正在使用带有GridLayoutManager的基本RecyclerView。我观察到smoothScrollToPosition和scrollToPosition都不能正常工作。a)在使用smoothScrollToPosition时,我经常收到来自RecyclerView的错误"RecyclerView﹕Passedovertargetpositionwhilesmoothscrolling."和RecyclerView未正确滚动(通常会错过目标行)。这主要是在我尝试滚动到某行的第一项时观察到的b)使用scrollToPosition时,它似乎工作得很好,但大多数时候我只能看到该

android - (Smooth)ScrollToPosition 不能与 RecyclerView 一起正常工作

我正在使用带有GridLayoutManager的基本RecyclerView。我观察到smoothScrollToPosition和scrollToPosition都不能正常工作。a)在使用smoothScrollToPosition时,我经常收到来自RecyclerView的错误"RecyclerView﹕Passedovertargetpositionwhilesmoothscrolling."和RecyclerView未正确滚动(通常会错过目标行)。这主要是在我尝试滚动到某行的第一项时观察到的b)使用scrollToPosition时,它似乎工作得很好,但大多数时候我只能看到该

android - 如何控制 recyclerView.smoothScrollToPosition(position) 的滚动速度?

我有一个回收站View,我希望平滑向下滚动,然后以编程方式向上滚动以向用户显示其中的完整内容。我可以这样做:finalintheight=recyclerView.getChildAt(0).getHeight();recyclerView.smoothScrollToPosition(height);recyclerView.postDelayed(newRunnable(){publicvoidrun(){recyclerView.smoothScrollToPosition(0);}},200);但我想要的是放慢滚动速度,让完整的内容清晰可见。 最佳答

android - 如何控制 recyclerView.smoothScrollToPosition(position) 的滚动速度?

我有一个回收站View,我希望平滑向下滚动,然后以编程方式向上滚动以向用户显示其中的完整内容。我可以这样做:finalintheight=recyclerView.getChildAt(0).getHeight();recyclerView.smoothScrollToPosition(height);recyclerView.postDelayed(newRunnable(){publicvoidrun(){recyclerView.smoothScrollToPosition(0);}},200);但我想要的是放慢滚动速度,让完整的内容清晰可见。 最佳答

android - 如何使用 Espresso 计数 RecyclerView 项目

使用Espresso和Hamcrest,如何计算recyclerView中可用的项目数?示例:我想检查5个项目是否显示在特定的RecyclerView中(必要时滚动)。 最佳答案 这里是一个查看RecyclerView项目计数的示例ViewAssertionpublicclassRecyclerViewItemCountAssertionimplementsViewAssertion{privatefinalintexpectedCount;publicRecyclerViewItemCountAssertion(intexpect

android - 如何使用 Espresso 计数 RecyclerView 项目

使用Espresso和Hamcrest,如何计算recyclerView中可用的项目数?示例:我想检查5个项目是否显示在特定的RecyclerView中(必要时滚动)。 最佳答案 这里是一个查看RecyclerView项目计数的示例ViewAssertionpublicclassRecyclerViewItemCountAssertionimplementsViewAssertion{privatefinalintexpectedCount;publicRecyclerViewItemCountAssertion(intexpect

android - RecyclerView 用它下面的 View 滑动

我一直在做一些研究,但我还没有找到一个示例或实现,允许您在滑动时在RecyclerView下方放置一个View(下面的示例图像)。有没有人有任何示例或想法如何不使用使用库来实现。这是我如何实现滑动关闭。ItemTouchHelper.SimpleCallbacksimpleItemTouchCallback=newItemTouchHelper.SimpleCallback(0,ItemTouchHelper.LEFT|ItemTouchHelper.RIGHT){@OverridepublicbooleanonMove(RecyclerViewrecyclerView,Recycle

android - RecyclerView 用它下面的 View 滑动

我一直在做一些研究,但我还没有找到一个示例或实现,允许您在滑动时在RecyclerView下方放置一个View(下面的示例图像)。有没有人有任何示例或想法如何不使用使用库来实现。这是我如何实现滑动关闭。ItemTouchHelper.SimpleCallbacksimpleItemTouchCallback=newItemTouchHelper.SimpleCallback(0,ItemTouchHelper.LEFT|ItemTouchHelper.RIGHT){@OverridepublicbooleanonMove(RecyclerViewrecyclerView,Recycle

android - 滚动时获取 RecyclerView 的中心可见项

这就是我想要的:如上图,我想在RecycleView上画一条中心线,然后在滚动时获取中心项(以及向左或向右移动)这是我尝试绘制水平的RecycleView:HorizontalAdapteradapter=newHorizontalAdapter(data);LinearLayoutManagerlayoutManager=newLinearLayoutManager(this,LinearLayoutManager.HORIZONTAL,false);recycleView.setLayoutManager(layoutManager);recycleView.setAdapter(