Android: Making a button visible once webview is done scrolling

后端 未结 5 1056
面向向阳花
面向向阳花 2020-12-19 10:18

I have a webview which shows an html file. When the user scrolls to the bottom of this file in webview, I want a button that was previously hidden to show up, which the user

5条回答
  •  没有蜡笔的小新
    2020-12-19 10:46

    try this:

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
            View view = (View) getChildAt(getChildCount()-1);
            int diff = (view.getBottom()-(getHeight()+getScrollY()));// Calculate the scrolldiff
            if( diff == 0 ){  // if diff is zero, then the bottom has been reached
                Log.d(ScrollTest.LOG_TAG, "MyScrollView: Bottom has been reached" );
                yourButton.setVisible(true);
            }
            super.onScrollChanged(l, t, oldl, oldt);
    }
    

    To implement this, extend ScrollView and then override the onScrollChanged method (inherited from View).

提交回复
热议问题