0

如果ScrollView向下滚动,它必须显示页脚。如果它向上滚动,则页脚必须禁用。怎么做这种东西?

4

1 回答 1

0

有人已经在评论中发布了这个,但无论如何都在这里。

@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        View view = (View) getChildAt(getChildCount()-1);
        int diff = (view.getBottom()-(getHeight()+getScrollY()));
        if( diff <= 0 ){ 
            yourFooter.setVisibility(View.GONE);
        }
        else{
            yourFooter.setVisibility(View.VISIBLE);
        }
        super.onScrollChanged(l, t, oldl, oldt);
}

扩展 ScrollView,然后重写 onScrollChanged 方法。

于 2013-03-28T10:29:30.750 回答