1

I want to make the tabs of a tabhost fade up if the user is scrolling down a listview

I have the following code but it does not work

ListView ls = (ListView) findViewById(R.id.list);
        ls.setOnScrollListener(new OnScrollListener() {
            public void onScrollStateChanged(AbsListView view, int scrollState) {

            }
            int previousVisible = 3;
            public void onScroll(AbsListView view, int firstVisibleItem,
                    int visibleItemCount, int totalItemCount) {
                if (previousVisible < firstVisibleItem) {
                    getParent().findViewById(android.R.id.tabhost)
                            .setVisibility(View.INVISIBLE);
                } else {
                    getParent().findViewById(android.R.id.tabhost)
                            .setVisibility(View.VISIBLE);
                }
                previousVisible = firstVisibleItem;
            }
        });
124697
  • 22,097
  • 68
  • 188
  • 315

1 Answers1

1

Lars Werkman has implemented an Android Library to implement this UI principle from Roman Nurik and Nick Butcher.

https://github.com/LarsWerkman/QuickReturnListView

Glenn Bech
  • 6,103
  • 4
  • 39
  • 56
  • Great but this lib seems not maintained – eVoxmusic Jan 19 '15 at 04:11
  • I am hoping Google wil add someting to the support libraries. They use a variant of this pattern in the Google Play Market app and the G+ app. It seems to be an "emerging" UI pattern. – Glenn Bech Jan 20 '15 at 11:51