You can create a view as a header from your list, and by recognizing the scroll, hide/show that view.
final HeaderView header = new HeaderView(getActivity(), json);
mListView.addHeaderView(header);
setOnScrollListener(new OnScrollListener(){
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
// TODO Auto-generated method stub
}
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
if(scrollState == 0) {
Log.i("a", "scrolling stopped...");
if (view.getId() == mListView.getId()) {
final int currentFirstVisibleItem = mListView.getFirstVisiblePosition();
if (currentFirstVisibleItem > mLastFirstVisibleItem) {
header.setVisibility(View.VISIBLE);
} else if (currentFirstVisibleItem < mLastFirstVisibleItem) {
header.setVisibility(View.GONE)
}
mLastFirstVisibleItem = currentFirstVisibleItem;
}
}
}
});
This answer is not the exact solution to the problem, but it is very close. I used the described methods to change the margin a Frame/Header out of the list, causing it to hide when rolled up, and appearing when rolled down. It didn’t work precisely because the margin change only occurs when the first visible item changes. I want something more precise. I tried to use getScrollY and getPositionScrollBar but only returns 0. Not yet this as I want.
– Fernando Gomes