txusballesteros/welcome-coordinator

Wrong background color output (demo app)

Opened this issue · 1 comments

Thanks for this awesome library!

I'm having some issues with the background color transition in the demo app.
To make this bug visible change the page colors in the demo app to this:

<color name="page1">#ff0000</color>
<color name="page2">#ffffff</color>
<color name="page3">#000000</color>
<color name="page4">#0000FF</color>

The expected output is that page 1 is red, page 2 white, page 3 black, page 4 blue.
Actual output:
Welcome coordinator color bug

I think this bug is due to float to int conversion.
I've tried to change this (here):

int maximumScroll = getMeasuredWidth() * numOfPages;

to this:

float maximumScroll = getMeasuredWidth() * numOfPages;

but that doesn't work.

Also why are the parameters in onScrollPage are not like the ViewPager.OnPageChangeListener parameters?

So from this:

public void onScrollPage(View v, float progress, float maximum)

to this:

public void onScrollPage(View v, int position, float positionOffset, int positionOffsetPixels)

For those who are still looking for a fix:
https://gist.github.com/GerritHoekstra/41b6a5b55f983c6db8985ad62fcc3929

I'm going to close this issue if it's fixed in the demo, for now I'll leave it open.