Skip to content

Instantly share code, notes, and snippets.

@shem8
Created April 25, 2016 06:15
Show Gist options
  • Save shem8/699352da50c20dd0ed3c40fd0796259d to your computer and use it in GitHub Desktop.
Save shem8/699352da50c20dd0ed3c40fd0796259d to your computer and use it in GitHub Desktop.
final View container = findViewById(R.id.container);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) container.getLayoutParams();
final CoordinatorLayout.Behavior<View> behavior = new CoordinatorLayout.Behavior<View>() {
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
return dependency.getId() == R.id.dismiss;
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
child.setX(dependency.getX());
child.setAlpha(dependency.getAlpha());
return true;
}
};
params.setBehavior(behavior);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment