Skip to content

Instantly share code, notes, and snippets.

@Sefford
Created December 18, 2014 11:54
Show Gist options
  • Save Sefford/213d011b38ace2a6c6ad to your computer and use it in GitHub Desktop.
Save Sefford/213d011b38ace2a6c6ad to your computer and use it in GitHub Desktop.
Helper method to gradually crossfade two tabs
void selectTab(Float scroll, int direction) {
float localOffset = scroll - scroll.intValue();
int intValue = scroll.intValue();
switch (direction) {
case 1:
views[intValue].setTextColor((int) argbEvaluator.evaluate(localOffset, selectedColor, unselectedColor));
if (intValue + 1 <= views.length - 1) {
views[intValue + 1].setTextColor((int) argbEvaluator.evaluate(localOffset, unselectedColor, selectedColor));
}
return;
case 0:
views[intValue].setTextColor((int) argbEvaluator.evaluate(1 - localOffset, unselectedColor, selectedColor));
views[intValue + 1].setTextColor((int) argbEvaluator.evaluate(1 - localOffset, selectedColor, unselectedColor));
return;
default:
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment