android中上下滑动listview,顶端和底端布局可以隐藏和显示

2024-11-15 01:56:00
推荐回答(3个)
回答1:

list.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState){
switch (scrollState) {

case SCROLL_STATE_FLING:
//滑动中隐藏view
break;

case SCROLL_STATE_IDLE:
//空闲的时候显示
break;
}

}

@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {

}
});

回答2:

listView.setOnScrollListener(new OnScrollListener() {

@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// 当不滚动时
if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
}
//第1次:scrollState = SCROLL_STATE_TOUCH_SCROLL(1) 正在滚动
//第2次:scrollState = SCROLL_STATE_FLING(2) 手指做了抛的动作(手指离开屏幕前,用力滑了一下)
//第3次:scrollState = SCROLL_STATE_IDLE(0) 停止滚动

}

@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
// TODO Auto-generated method stub
}
});

回答3:

可以设置顶端和底端的高度或者位置,这样就相当于看不见了