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

查看:267
本文介绍了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?

推荐答案

,您可以将此属性添加到线性布局中.您的scrollView的线性布局"直接子级.

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天全站免登陆