FloatingActionButton does not come down when dismissing Snackbar

后端 未结 3 1975
Happy的楠姐
Happy的楠姐 2020-12-31 10:49

I am trying to use a Snackbar. I have a FloatingActionButton wrapped in a CoordinatorLayout. When the Snackbar shows, the

3条回答
  •  孤城傲影
    2020-12-31 11:13

    Try this:

    Snackbar mysnack = Snackbar.make( fab, "Hi, welcome to my app!", Snackbar.LENGTH_LONG );
    mysnack.getView().addOnAttachStateChangeListener( new View.OnAttachStateChangeListener() {
        @Override
        public void onViewAttachedToWindow( View v ) {
    
        }
    
        @Override
        public void onViewDetachedFromWindow( View v ) {
            fab.setTranslationY( 0 );
        }
    });
    mysnack.show();
    

提交回复
热议问题