ConstraintLayout parentLayout = (ConstraintLayout)findViewById(R.id.main_parent_layout);
ConstraintSet set = new ConstraintSet();
ImageView childView = new ImageView(this);
childView.setId(View.generateViewId());
layout.addView(childView, 0);
set.clone(parentLayout);
set.connect(childView.getId(), ConstraintSet.TOP, parentLayout.getId(), ConstraintSet.TOP, 60);
set.connect(childView.getId(), ConstraintSet.BOTTOM, parentLayout.getId(), ConstraintSet.BOTTOM, 22);
set.connect(childView.getId(), ConstraintSet.START, otherView.getId(), ConstraintSet.START, 22);
set.applyTo(parentLayout);
stackoverflow