有时开发中有这样的需求,滑动到一定高度显示标题 小于此高度 隐藏
针对使用headerview 情况
办法如下:
假设 int requiredHeight = 100;
listview 的setOnScrollListener
onScroll方法中
int top = headerView.getTop();
int h = Math.abs(top);
if (h < 100) {
requiredView.setVisibility(View.INVISIBLE);
} else {
requiredView.setVisibility(View.VISIBLE);
}
本文介绍了一种在Android开发中根据ListView滚动位置显示或隐藏标题的方法。通过设置特定的高度阈值,实现当滑动到一定高度时显示标题,反之则隐藏。
1万+

被折叠的 条评论
为什么被折叠?



