Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何整体滚动android recyclerView,而不是基于元素的焦点?_Android_Scroll_Android Recyclerview - Fatal编程技术网

如何整体滚动android recyclerView,而不是基于元素的焦点?

如何整体滚动android recyclerView,而不是基于元素的焦点?,android,scroll,android-recyclerview,Android,Scroll,Android Recyclerview,我有一个android TV的recyclerView,它有一个FAQ类型的屏幕,即一个问题和一个答案,我正在使用适配器将数据输入其中 回收视图布局- <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/recyclerview" android:layout_width="match_parent" andro

我有一个android TV的recyclerView,它有一个FAQ类型的屏幕,即一个问题和一个答案,我正在使用适配器将数据输入其中

回收视图布局-

<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:scrollbarThumbVertical="@color/white"
android:scrollbarSize="5px"
android:fadeScrollbars="false"
android:requiresFadingEdge="vertical"
android:fadingEdgeLength="150px">
</android.support.v7.widget.RecyclerView>
关于创作的观点并非每次都可靠


欢迎使用任何解决方案。

尝试安装您的recyclerview适配器

 @Override
    public long getItemId(int position) {
        return super.getItemId(position);
    }

和sethasstableId(true);在填充数据或接收列表之前(在setData之前(列出一些)或在适配器的构造函数中)。然后尝试使用您的
recyclerView.smoothScrollToPosition(5)

您可以创建包含5个问题答案的行,然后滚动一次。recyclerView可以像查看页面一样设置动画。如果您使用该功能。然后,在第一个5个问题答案中,您的行布局中出现了,。当您滚动一次时,。它将显示nect 5问题答案不建议同时使用5个QnA,因为结构需要为1个QnA,然后根据适配器中的数据绑定。还有其他想法吗?谢谢你的回答,丹尼尔。然而,这不起作用,相反,每次从上到下滚动时,我的数据都会变得混乱,反之亦然。您是否在适配器中使用了LinearLayoutManager?因为您可以尝试使用此linearLayoutManager移动;是的,我也用过。但正如我在问题中提到的,根据动态内容,屏幕底部也可能是第7个问题或第3个问题,因此recyclerView.smoothScrollToPosition(5)不会每次都在这种情况下工作。但我建议与linearlayoutmanager一起使用,而不是像您那样与recyclerView一起使用。你也尝试过吗?我的问题通过使用scrollview解决了,因为我不需要孩子们聚焦。但是没有找到主要问题的答案。
recyclerView.smoothScrollToPosition(5)
 @Override
    public long getItemId(int position) {
        return super.getItemId(position);
    }