-2

Currently, I have a webView with custom relativeLayout header, and when I scroll up, the webView the header should be hidden.
And when I scroll down the header should be visible.

Please suggest me any idea about.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

2 Answers2

0

You will have to implement scroll listener for that. see this

After implementing scroll listener for webview, you will get two conditions (up scroll & down scroll).

so, hide your relative layout header on scroll down and show it on scroll up.

wv.setOnScrollChangedCallback(new OnScrollChangedCallback(){
    public void onScroll(int l, int t, int oldl, int oldt){
        if(t> oldt){
            header.setVisibility(View.VISIBLE);
        }
        else if(t< oldt){
            header.setVisibility(View.GONE);
        }
    }
});

You can also make an animation transition for the same for the better user experience.

Community
  • 1
  • 1
Prayag Gediya
  • 1,078
  • 2
  • 11
  • 20
-1

wv.setOnScrollChangedCallback(new OnScrollChangedCallback(){
    public void onScroll(int l, int t, int oldl, int oldt){
        if(t> oldt){
            header.setVisibility(View.VISIBLE);
        }
        else if(t< oldt){
            header.setVisibility(View.GONE);
        }
    }
});

when i implement this code then at the time of scrolling both condition are executing.that's why its showing visible and gone at the same time.