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
addOnScrollListener(new OnScrollListener() { | |
@Override | |
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
super.onScrolled(recyclerView, dx, dy); | |
if (getLayoutManager() instanceof LinearLayoutManager) { | |
LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager(); | |
if (layoutManager.getOrientation() == LinearLayoutManager.VERTICAL) { |
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) { |