I have a dynamically created ImageView in one ConstraintLayout. Once I run the app the ImageView is showing on left top corner because no position is defined for the ImageView.
How can I set the position(let's say CENTER) of the ImageView dynamically?
I have written the below code:
ConstraintLayout layout = (ConstraintLayout) findViewById(R.id.constraintLayout);
ImageView imageView = new ImageView(ChooseOptionsActivity.this);
imageView.setImageResource(R.drawable.redlight);
layout.addView(imageView);
setContentView(layout);
Any suggestion is highly appreciated.