In Android, I defined an ImageView
\'s layout_width
to be fill_parent
(which takes up the full width of the phone).
If the imag
This is how it worked for me inside a ConstraintLayout:
Then in code, I set the drawable as:
ImageView imgView = findViewById(R.id.myImg);
imgView.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.image_to_show, null));
This fits the image nicely according to its aspect ratio and keeps it in centre.