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

Can't scroll vertically in 3.0 #371

Open
Maragues opened this issue Feb 19, 2016 · 4 comments
Open

Can't scroll vertically in 3.0 #371

Maragues opened this issue Feb 19, 2016 · 4 comments

Comments

@Maragues
Copy link

Hi, I upgraded to Caldroid 3.0 and I can't scroll vertical anymore when the phone is in landscape.

The only difference I can see (using Android Device Monitor) is that the ViewPager (presumably managed by InfiniteViewPager) is focusable, whereas on 2.2.1 it wasn't.

You made some changes to InfiniteViewPager (75117ee#diff-573a72554170d4605348f2a96c1d3eb1), but I don't see how that could affect the scrolling.

This might be more a StackOverflow question, but maybe you are aware of a change that could result in this behaviour.

@thomasdao
Copy link
Contributor

I think the difference here is that Caldroid now calculates height of the viewpager correctly so it can be used safely in scrollview (previously client would need to wrap CaldroidFragment inside a fix height LinearLayout instead of wrap_content if it's used inside scrollview). And also now instead of scrolling the fragment, I modified the sample so it scrolls the whole screen instead. If you turn phone to landscape I believe you could scroll the whole screen vertically

@Maragues
Copy link
Author

Thanks @thomasdao

Not exactly related to this issue's description, but I've created a PR (#376) that fixes the issues I was having with scrolling

@Maragues
Copy link
Author

Ok, I finally found why GridView is not handling scrolling on this library. To me, it was very weird that a GridView was wrapped by a ScrollView, and I didn't want the whole View (month name + calendar) to scroll but only the Calendar.

Here goes the explanation:

Since InfiniteViewPager's height is fixed and all rows fit in, all of the GridView's children are considered to be visible, because their mBottom property is always above GridViews mBottom. Hence, when the GridView is asked if it needs scrolling, it always says "No, I'm ok, all of my views are visible".

I've forked Caldroid and removed the onMeasure in InfiniteViewPager, which inmediately resulted in GridView taking control of scrolling. Since I haven't seen anyone complain about this, I'll leave that code in my fork.

You can now close this issue, but I would expect more people to complain about it.

See https://github.com/Maragues/Caldroid/blob/master/caldroid/src/main/java/com/antonyt/infiniteviewpager/InfiniteViewPager.java

If anyone is interested on how an AbsListView decides whether it needs scrolling or not, check https://github.com/android/platform_frameworks_base/blob/master/core/java/android/widget/AbsListView.java#L4912

@Maragues
Copy link
Author

PR #376 is still valid and will prevent unwanted scrolling when adding verticalSpacing

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

No branches or pull requests

2 participants