How To Hide And Show A Layout On Scrolling Down A Scroll View In Android?
I have a particular layout which consist a scroll view and an image which is at bottom of the activity. My question is that when I start scrolling up that image will not visible an
Solution 1:
You can achieve this easily with android support widget CoordinatorLayout. Follow this post to hide/show the image based on scrolling.
You can learn more about coordinator layout here
Solution 2:
scrollView.getViewTreeObserver().addOnScrollChangedListener(newViewTreeObserver.OnScrollChangedListener() {
@OverridepublicvoidonScrollChanged() {
if (scrollView != null) {
if (scrollView.getChildAt(0).getBottom() <= (scrollView.getHeight() + scrollView.getScrollY())) {
relativeLayout.setVisibility(View.VISIBLE);
}
else {
relativeLayout.setVisibility(View.INVISIBLE);
}
}
}
});
Post a Comment for "How To Hide And Show A Layout On Scrolling Down A Scroll View In Android?"