Created
June 16, 2017 13:52
-
-
Save developer-shivam/10b59bb4eb292d2de33ac638577db4e5 to your computer and use it in GitHub Desktop.
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 changeHeightAccordingToScroll(RecyclerView recyclerView) { | |
for (int i = 0; i < totalItemsInView; i++) { | |
View viewToBeResized = recyclerView.getChildAt(i); | |
if (viewToBeResized != null) { | |
float distance = getTopOfView(viewToBeResized); | |
if (distance > maxDistance) { | |
viewToBeResized.getLayoutParams().height = defaultItemHeight; | |
viewToBeResized.requestLayout(); | |
} else if (distance <= maxDistance) { | |
viewToBeResized.getLayoutParams().height = (int) height(distance); | |
viewToBeResized.requestLayout(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment