SHARE
TWEET

SnackBarFABBehavior

a guest Jul 23rd, 2015 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Created by tilemachos on 7/23/15.
  3.  */
  4. public class SnackBarFABBehavior extends ScrollingFABBehavior {
  5.  
  6.     public SnackBarFABBehavior(Context context, AttributeSet attrs) {
  7.         super(context, attrs);
  8.     }
  9.  
  10.     @Override
  11.     public boolean layoutDependsOn(CoordinatorLayout parent, FloatingActionButton fab, View dependency) {
  12.         return super.layoutDependsOn(parent, fab, dependency) || (dependency instanceof Snackbar.SnackbarLayout);
  13.     }
  14.  
  15.     @Override
  16.     public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton fab, View dependency) {
  17.  
  18.         if (dependency instanceof Snackbar.SnackbarLayout){
  19.             float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
  20.             fab.setTranslationY(translationY);
  21.         }
  22.         return super.onDependentViewChanged(parent, fab, dependency);
  23.     }
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top