Slide 21
Slide 21 text
Example: FloatingActionButton.Behaviour
public class ExampleBehaviour extends Behavior {
@Override
public boolean layoutDependsOn(final CoordinatorLayout parent, final FloatingActionButton child,
final View dependency) {
return dependency instanceof Snackbar.SnackbarLayout;
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child,
View dependency) {
if (dependency instanceof Snackbar.SnackbarLayout) {
float dependencyTranslationY = ViewCompat.getTranslationY(dependency);
float translationY = Math.min(0, dependencyTranslationY - dependency.getHeight());
ViewCompat.animate(child).translationY(translationY);
return true;
}
return false;
}
}