-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
canScrollHorizontally() crashes if the RecyclerView is not attached to the Window #474
Comments
I'm seeing a very similar crash when I try to nest
Also relevant is that the inner Incidentally, I'm using inner |
Hi @martinbonnin, Thanks for the report. I checked your repository, but the activity_main only has a top-level ConstraintLayout. And the app didn't crash when I launched the app. |
@thagikura thanks for looking into this. The crash happens on a Nexus 9 tablet with Android 6.0. I tried to reproduce on a Pixel 3 XL but the crash did not happen indeed. So I guess it depends the framework version :-/. main_activity.xml is really empty on purpose, the trick is to create a RecyclerView programmatically and not attach it to any parent. |
have you managed to solve this issue? I'm getting the same. |
@bgorkowy I workaround'd the issue for now |
A workaround is to clone the library and perform a check on line 1901 |
…yclerView is not attached to the Window
We have this use case where we might call
recyclerView.smoothScrollToPosition
on a view that has been removed from its container. In that case, we get the following crash:Sample code to reproduce the issue => https://github.com/martinbonnin/FlexboxTest. It mainly boils down to:
I understand scrolling on a non-visible View is not the most useful thing to do but I would still expect the LayoutManager to handle this case gracefully ?
The text was updated successfully, but these errors were encountered: