Created
May 2, 2018 17:10
-
-
Save Gryzor/2e50f4eb29474e2b8cd9c1d912703e85 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
private void configureViews() { | |
// Create a Constraint Set and clone our constraints | |
ConstraintSet constraintSet = new ConstraintSet(); | |
// Create our progress bar… | |
ProgressBar progressBar = new ProgressBar(getContext(), null, android.R.attr.progressBarStyleLarge); | |
progressBar.setIndeterminate(true); | |
progressBar.setId(generateViewId()); | |
// Add it to our hierarchy | |
addView(progressBar, new ConstraintLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); | |
// Now that the hierarchy is complete… | |
constraintSet.clone(this); | |
// Configure its constraints … basically pin it to every side. | |
constraintSet.connect(progressBar.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP); | |
constraintSet.connect(progressBar.getId(), ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM); | |
constraintSet.connect(progressBar.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START); | |
constraintSet.connect(progressBar.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END); | |
// Now apply the new constraints | |
constraintSet.applyTo(this); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment