Skip to content
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

Scrolling issues #55

Closed
GoodSir42 opened this issue Mar 5, 2015 · 58 comments
Closed

Scrolling issues #55

GoodSir42 opened this issue Mar 5, 2015 · 58 comments

Comments

@GoodSir42
Copy link

Hi,

I think I found another issue:

I have a grid layout with variable size cards. If the first card in the last line is bigger than the rest it is cut off. Also I can't scroll back to the top in this case.

The layout item is completely displayed if I first scroll down and then turn the display (probably repainting the view)

Edit: I am using the width-based version of the grid layout.
Edit 2: If I scroll fast enough I will get the complete item visible

@PatrickDattilio
Copy link

This sounds like a StaggeredGridView, which is not yet supported.

@GoodSir42
Copy link
Author

It sounds like one, but it is not ;) Due to the fact that staggered layouts are not yet supported I put the views in a grid. It works perfectly fine if the biggest item is not the first one in a grid row, so there must be some small measuring issue. I am trying to find it right now, but it's quite hard if you don't know where to look.

@TonicArtos
Copy link
Owner

Grid layout does handle different height items but makes the row fit the max row item height. I am not seeing this error in v0.4.4.

@GoodSir42
Copy link
Author

I am, though (also using 0.4.4). How can I help you to reproduce this? Unfortunately I can not provide the project itself.

@GoodSir42
Copy link
Author

Where's the max row height calculated? Perhaps I can fix it myself.

@TonicArtos
Copy link
Owner

GridSLM#fillRow(…)

@TonicArtos
Copy link
Owner

However, there seems to be a problem passing through margins in the layout params.

@GoodSir42
Copy link
Author

Even if I remove the margins I can not scroll back to the top any more. I will have a look at this tomorrow if you can't reproduce it.

@TonicArtos
Copy link
Owner

Okay the margin issue is just a red herring, the margins were being stripped as they were passed through the grid layout layout param constructor.

Anyway, there is actually something strange going on with CardView. Sometimes cards are not measuring as the same size.

@TonicArtos
Copy link
Owner

Is the card view completely cut off? Or is text content cut off? If it is the latter, then I think it is basically the same issue as #56. I suggest making sure you are using different view type ids for views going to different layouts, and for headers too.

@GoodSir42
Copy link
Author

The card view is completely cut off. I am also using different view types, but the views themselves are of a dynamic height. I will display some dummy values and post a few screen shots later.

@GoodSir42
Copy link
Author

I just hit the autocompletion a few times to fill some text views. Here are my results:

scroll_works
If the second card is bigger than the first one everythingn is ok.

scroll_broken
However if the first one is bigger the recycler view doe snot scroll any more and cards may be cut off if I scroll there slowly. If I scroll to the position with a fast movement I see the complete card (as in the image).

@TonicArtos
Copy link
Owner

Are those TextEdit views inside the cards? Maybe that is related.

@GoodSir42
Copy link
Author

Yes, but the issue is not related. They were just the only ones I could fill easily.
I set the values by typing into a dialog and then call settext on the EditText later.

The issue also happens with LinearLayouts that I fill programmatically (that was the original reason). It really seems to depend on the size of the views.

@GoodSir42
Copy link
Author

I also get weird values from getDecoratedBottom(). They seem to be changing based on the scroll speed.

@GoodSir42
Copy link
Author

I think I found the issue that blocks the scrolling, but I don't think that this was the original problem...

Look at this commit in my fork, please: https://github.com/Eifelschaf/SuperSLiM/commit/90f6c8b4c0e9f203554a7874fe3c607f55c54325

Does this make sense? This change allows me to scroll up at least (still with the cut card)

@TonicArtos
Copy link
Owner

If that early return is the issue then it means the section bottom edge is not being calculated properly.

@TonicArtos
Copy link
Owner

Hang on, is this only happening for the very last item in the entire (super) layout, not just a grid layout?

@TonicArtos
Copy link
Owner

Aha, there we go.

@GoodSir42
Copy link
Author

Yes, I think I nailed it down. The getAnchorAtEnd() return the last view, not the biggest in the last row :)
This is why it only appears in the grid layout..

@TonicArtos
Copy link
Owner

The reason for the cut off is that the grid is not computing the bottom edge correctly, so the scroll is not advancing to the real end of the layout.

@TonicArtos
Copy link
Owner

Yeah, getAnchorAtEnd should be passing through to the SLM.

@GoodSir42
Copy link
Author

Do you think it's a big deal to get this fixed?

@TonicArtos
Copy link
Owner

Actually, it should be using getAnchorAtEnd, it should be asking the SLM directly for the bottom edge.

@TonicArtos
Copy link
Owner

It should be a minor fix. Give me a couple of minutes and I'll push a snapshot for you to test.

@TonicArtos
Copy link
Owner

Yeah, it was trivial to fix. I am just testing it now. There are some other small fixes that have been pulled together with this and I want to check it is all working together.

@GoodSir42
Copy link
Author

Sure, take your time.

TonicArtos added a commit that referenced this issue Mar 6, 2015
- Fix scroll at content end with grid. Closes #55.
- Lots of minor fixes.
- - Layout params copy constructor using margin params source.
- - Actually trim children below the screen before whole section has passed.
- - Better anchor finding for fill next section to start.
- - While filling row, don't look into next section.
- - Better naming for column anchor position.
- - Decache the correct view.
- - Remove dead code.
- - Add layout params copy constructor using margins layout source.
@GoodSir42
Copy link
Author

stop.. I just encountered it again. I have to re-check this...

@GoodSir42 GoodSir42 reopened this Mar 6, 2015
@GoodSir42
Copy link
Author

OK, the scrolling is fixed, but the card is still cut if I scroll slowly. Are you sure you forward the measurement calls everywhere?

@TonicArtos
Copy link
Owner

Yeah, I am seeing the bug in master after merging it, but not on the release branch. There is something I have to check.

@GoodSir42
Copy link
Author

As I said: take your time :)

@TonicArtos
Copy link
Owner

Oh, hey, can you make sure to refresh the snapshot? Because there were two copies released close to each other, the unfixed one might be cached on your machine. Just to be sure.

@GoodSir42
Copy link
Author

I only got it after the second release, but I will check again.

@TonicArtos
Copy link
Owner

I am definitely not seeing the bug anymore. I fixed the code divergence on master too.

@GoodSir42
Copy link
Author

I just did a full rebuild with 0.4.5-snapshot and it's still there.. did you try scrolling slowly?

@TonicArtos
Copy link
Owner

Yeah, slow scrolling is fine here. I've tested with a number of views including EditText. I just noticed couple of bugs with EditText, but they are quite different (performance and keyboard interaction).

@GoodSir42
Copy link
Author

I will quickly try a rebuild with the current source code. It's the early_release_4 branch, right?

@TonicArtos
Copy link
Owner

Yes

@GoodSir42
Copy link
Author

Nope, still there, even with the latest source. I will have a look at it now and let you know if I find something more specific.

@GoodSir42
Copy link
Author

As I thought: the scrollVerticallyBy method still uses the wrong view for measurement

@GoodSir42
Copy link
Author

ahhh shit.. This may have been my fault...

@TonicArtos
Copy link
Owner

Okay. Here is what should be happening. On scroll a leading edge is calculated. For a scroll towards the end of the content that edge is the height of the view + the scroll displacement.

To fill the leading are in the scroll, the gridSlm should be measuring and laying out content row by row, up to that edge. The line (markerLine) up to which the grid has filled should be the bottom of the last grid row laid out.

The fix to this problem was an adjustment to use the SLM to calculate the end of the content (grid slm knows about rows, layout manager does not), rather than assuming the anchor position is at the bottom edge.

@GoodSir42
Copy link
Author

OK. It's fixed. It was just some very weird behavior:

I removed all sectionmanager markups from my non-header views as they were ignored for layout anyways. Turns out that they are taken into account to get the slm for measurement now.

@TonicArtos
Copy link
Owner

and in v0.5.0 they don't matter again

@TonicArtos
Copy link
Owner

Actually, they were not quite always ignored. For the scroll indicator they are required in v0.4.x.

@GoodSir42
Copy link
Author

great! Thanks! I will go with the current solution for now (multiple markup) and wait for 0.5 to change them.

@TonicArtos
Copy link
Owner

Yeah, sorry. It is a pain, I know. :(

@GoodSir42
Copy link
Author

It's ok as long as it works :) Thanks for helping me.

@TonicArtos
Copy link
Owner

But now I have two more problems to fix for EditText.

@TonicArtos
Copy link
Owner

:) You're welcome, reporting bugs helps me too.

@GoodSir42
Copy link
Author

If i can help you with the edit text just let me know.

@TonicArtos
Copy link
Owner

Thanks for offering. I am going to tackle it after #53. I will have to make a number of changes to the layout code so I might be able to fix it with that anyway.

@TonicArtos
Copy link
Owner

Alright, v0.4.5 should be available now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants