Reputation: 423
I have one nested scrollview, within this one is autoscroll view pager and 4 recycler views one below the other. When the nested scroll view scrolls up and the last recycler view appears on the top a filter button should get visible to the header section. How can I manage visibility of button when Last recycler view comes at the top. 2 snaps are here for example:
first:
second is the view when the last recycler view comes on Top and filter button get visible on the header.
Please Help.
Upvotes: 2
Views: 138
Reputation: 2471
Use this for NestedScrollView to check that if your salon list is visible and if it is then you can show the filter icon else make its visibility gone.
Rect scrollBounds = new Rect();
nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
nestedScrollView.getHitRect(scrollBounds);
if (salonRecyclerView.getLocalVisibleRect(scrollBounds)) {
// Here make visible the filter icon since you salon list is visible
if (!filterIcon.isVisible()) {
filterIcon.setVisible(View.VISIBLE);
}
} else {
// Here make visible GONE of filter icon since you salon list is not visible
if (filterIcon.isVisible()) {
filterIcon.setVisible(View.GONE);
}
}
}
});
Upvotes: 2