Created
August 14, 2020 17:49
-
-
Save yuriyskulskiy/d9f9b3cc460f471cf7156fa1f54e55b3 to your computer and use it in GitHub Desktop.
AnimatedLayout_part_2 update child during scrolling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void updateOffset(float newOffsetValue) { | |
... | |
updateIconView(); | |
} | |
private void updateIconView() { | |
float oldTranslatePosition = mWeatherIcon.getTranslationX(); | |
float newTranslatePosition; | |
float newAlpha; | |
if (mOffsetValue < getWidth() / 2f) { | |
newTranslatePosition = mOffsetValue; | |
if (oldTranslatePosition > 0) { | |
applyWinterIcon(); | |
} | |
float alphaPass = getWidth() / 2f; | |
newAlpha = 1 - newTranslatePosition / alphaPass; | |
} else { | |
newTranslatePosition = mOffsetValue - getWidth(); | |
if (oldTranslatePosition < 0) { | |
applySummerIcon(); | |
} | |
float alphaPass = getWidth() / 2f; | |
newAlpha = 1 + newTranslatePosition / alphaPass; | |
mWeatherIcon.setAlpha(newAlpha); | |
} | |
mWeatherIcon.setAlpha(newAlpha); | |
mWeatherIcon.setTranslationX(newTranslatePosition); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment