The 29th Saltshaker The 29th Saltshaker - 4 months ago 21
Android Question

Hiding FloatingAction items when you scroll to the bottom of a list?

So if you have a RecyclerView that extends to the end of the screen and use a FloatingActionButton or the third-party FloatingActionMenu, then there is a slight problem with cover-up: If you scroll to the end of the list, the floating button covers up part of the row and there is no way to see or get to what's underneath it.

Is there a way Android allows you to:

  1. Detect if your list has a sufficient number of items in it, i.e. if there is a row at the bottom of the screen visible.


  1. Slide the buttons out of the way if you scroll down to the very end, and then slide them back in if you start scrolling back up?

Edit: Or, alternatively, add dynamic padding to the end of the RecyclerView that only shows up if you've scrolled all the way down?


The common pattern to solve the problem of covering up parts of UI is to hide FAB as soon as the user starts scrolling down ... You can achieve this by this code fragment (used with RecyclerView):

    fDemandsRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if(dy > 0 ){
                if(fFab.isShown()) fFab.hide();
            } else {

If you insist on hiding it on the very end and you are using RecyclerView with LinearLayoutManager, you can check method findLastCompletelyVisibleItemPosition() on the LayoutManager object during the OnScrollListener callback ...