只有当ScrollView向下滚动时,如何才能显示页脚?

时间:2013-03-28 10:20:47

标签: android scrollview android-scrollview android-scroll android-scrollbar

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

1 个答案:

答案 0 :(得分: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方法。

相关问题