如果向下滚动ScrollView
,则必须显示页脚。如果它向上滚动,那么页脚必须禁用。怎么做这种事?
有人已经在评论中发布了这个,但无论如何这里是。
@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方法