emilsjolander/StickyScrollViewItems

how Change background color

Opened this issue · 1 comments

how Change background color transparent to solid color of sticky element after scrolling complete

scrollView.getViewTreeObserver().addOnScrollChangedListener(() -> {
            int scrollY = scrollView.getScrollY(); // For ScrollView
            int scrollX = rootScrollView.getScrollX(); // For HorizontalScrollView
            Log.d("Scroll", "y = " + scrollY);
            if(scrollY < 100){ // within the top 100 pixels
                //Change background color to transparent when you are at the top
                topMenu.setBackgroundColor(getResources().getColor(R.color.transparent));
            }
            else{
                //Change background color to something else when you scroll down
                topMenu.setBackgroundColor(getResources().getColor(R.color.white));
            }

        });