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

Black Space When Flinging on ScrollView #64

Open
kwelsh opened this issue Sep 29, 2015 · 3 comments
Open

Black Space When Flinging on ScrollView #64

kwelsh opened this issue Sep 29, 2015 · 3 comments

Comments

@kwelsh
Copy link

kwelsh commented Sep 29, 2015

I'm not sure if this is reported or not, but I'm noticing some black space between the bottom of the header and the top of the ScrollView when you fling. The device I'm on is The Note 5 and I'm compiling from Gradle like such compile 'com.github.carlonzo.stikkyheader:core:0.+'

The code I'm seeing this with is the example code for SimpleScrollViewFragment.java and fragment_simplescrollview.xml, unmodified.

Is this a known issue and are there any workarounds? There doesn't seem to be a HeaderStikkyAnimator with this code, so I'm guessing it's in the way we measure the bottom of the header or the top of the ScrollView perhaps?

@kwelsh
Copy link
Author

kwelsh commented Sep 29, 2015

I've noticed that giving a max_height_header of 700dp (or something substantially large) and attempting to fling creates a pause during the middle of the fling. Flinging doesn't seem to be smooth, so I'm wondering what we're doing that is preventing it from smoothly scrolling the view.

The measurement of the sticky header seems to not be calculated as accurately while in the middle of flinging. Flinging makes the header appear to "bounce", as the top and bottom of the header adjust to the resizing of the layouts.

Where is the layout of the header measured when flinging occurs?

@luciovicentini
Copy link

Same behaviour is happening to me.

I made the scrollview parent (RelativeLayout) and the scrollview have the same background color as a workaround, but It would be nice to have a proper solution to this issue.

Thanks in advance.

@juanvimartinez
Copy link

I found a workaround for this issue.
In the BaseStickyHeaderAnimator.java file I added the following changes:

@Override
public void onScroll(int scrolledY) {
    StikkyCompat.setTranslationY(mHeader, Math.max(scrolledY, getMaxTranslation()));
    mTranslationRatio = calculateTranslationRatio(scrolledY - 0.01f);
}

private float calculateTranslationRatio(float scrolledY) {
        //TODO check divisor != 0
    return scrolledY / (float) getMaxTranslation();
}

With these changes, the blank space when flinging disappears after a small "jump".

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

3 participants