Screen:
Good afternoon to everyone. I want to set the image to a ImageView size relative to the parent container as a percentage. But the size of the picture does not change.
ConstraintLayout constraintLayout = new ConstraintLayout(this);
constraintLayout.setId(View.generateViewId());
ConstraintSet set = new ConstraintSet();
ImageView contactUs = new ImageView(this);
contactUs.setImageResource(R.drawable.rezgoriz);
contactUs.setId(View.generateViewId());
constraintLayout.addView(contactUs, 0);
set.clone(constraintLayout);
set.constrainPercentHeight(constraintLayout.getId(), 20);
set.constrainPercentWidth(constraintLayout.getId(), 20);
set.applyTo(constraintLayout);
setContentView(constraintLayout);
I'd appreciate any help. If anyone knows a publication in which is very detailed how to program in ConstraintLayout
with good examples, I will also be grateful.