Android 阻止嵌套的 recyclerview 自动重新定位 [英] Android prevent nested recyclerview from automatically repositioning

查看:29
本文介绍了Android 阻止嵌套的 recyclerview 自动重新定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ViewPager 作为线性布局中的一个项目,视图分页器中的每个项目都包含一个 RecyclerView.问题是,每当页面最初加载时,或者当我在 ViewPager 上更改页面时,视图都会自动滚动,因此回收器视图的开头是屏幕顶部,而不是保持原样.

I have a ViewPager as an item in a Linear Layout, with each item in the view pager containing a RecyclerView. The problem is, whenever the page initially loads, or when I change pages on the ViewPager, the view automatically scrolls so the beginning of the recycler view is the top of the screen, rather than staying how it is.

问题的 .gif 文件在 此处.注意我没有向下滚动,那是自动重新定位.

A .gif of the issue is here. Note I am not scrolling down, that is the automatic repositioning.

如何防止视图自动重新定位到回收器视图的开头?

How can I prevent the view from automatically repositioning to the start of the recycler view?

推荐答案

您可以将此属性添加到您的线性布局中.滚动视图的线性布局直接子项.

you can add this attribute to your linear layout. The Linear Layout direct child of your scrollView.

    android:descendantFocusability="blocksDescendants"

这篇关于Android 阻止嵌套的 recyclerview 自动重新定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆