Created
September 20, 2017 06:59
-
-
Save jack24254029/288ad030a2d8dad29648e0e45710e673 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConstraintLayoutBehavior extends CoordinatorLayout.Behavior<ConstraintLayout> { | |
public ConstraintLayoutBehavior(Context context, AttributeSet attributeSet) { | |
super(context, attributeSet); | |
} | |
@Override | |
public boolean layoutDependsOn(CoordinatorLayout parent, ConstraintLayout child, View dependency) { | |
return dependency instanceof Snackbar.SnackbarLayout; | |
} | |
@Override | |
public boolean onDependentViewChanged(CoordinatorLayout parent, ConstraintLayout child, View dependency) { | |
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight()); | |
child.setTranslationY(translationY); | |
return true; | |
} | |
@Override | |
public void onDependentViewRemoved(CoordinatorLayout parent, ConstraintLayout child, View dependency) { | |
child.setTranslationY(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment