Skip to content

Instantly share code, notes, and snippets.

@Subtle-fox
Created June 29, 2018 12:55
Show Gist options
  • Save Subtle-fox/784c638d66f18ba693a0c481953bcdda to your computer and use it in GitHub Desktop.
Save Subtle-fox/784c638d66f18ba693a0c481953bcdda to your computer and use it in GitHub Desktop.
Modify constraints programmatically
ConstraintSet set = new ConstraintSet();
ConstraintLayout layout;
layout = (ConstraintLayout) findViewById(R.id.layout);
set.clone(layout);
// The following breaks the connection.
set.clear(R.id.bottomText, ConstraintSet.TOP);
// Comment out line above and uncomment line below to make the connection.
// set.connect(R.id.bottomText, ConstraintSet.TOP, R.id.imageView, ConstraintSet.BOTTOM, 0);
set.applyTo(layout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment