Search code examples
androidfloating-action-button

extended floating action button for scrren swipe


Hi I want to make an Extended floating action button when I swipe up my screen it will become shrink, and when I swipe down it will be extended. I tried a lot to search this answer but not found that's why I asked this question. thanks in advance


Solution

  • if you are making it visible or invisible using recyclerview scroll

    then

        recyclerView.addOnScrollListener( new RecyclerView.OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                if (dy < 0)
                    floatingActionbutton.hide();
                else if (dy > 0)
                    floatingActionbutton.show();
            }
    
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged( recyclerView, newState );
            }
        } );