扩展的浮动操作按钮,可快速滑动

时间:2020-10-05 09:54:42

标签: floating-action-button

您好,我想在屏幕上滑动时将其设置为扩展浮动动作按钮,而在向下滑动时将其扩展。我尝试了很多搜索此答案,但没有发现这就是为什么我问这个问题。预先感谢

1 个答案:

答案 0 :(得分:0)

如果您使用recyclerview滚动使其可见或不可见

然后

    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 );
        }
    } );