I\'m trying to display an image centered in parent with a dimension ratio of 1220:1000 AND a maximum height of 300dp (to keep the image small even with large screen)
If you want to maximize the area with a dimension ratio and a max height, but you don't know if width or height is going to be adjusted, better don't to use layout_constraintDimensionRatio
+ layout_constraintHeight_max
. They don't work well together.
Here I put my solution in the case you have an image 16:9 which will use full width while max height is not yet reached, otherwise it will respect max height, and width will be adjusted:
I used a custom ImageView
I had in my gist which adjusts to aspect ratio, in order to avoid using layout_constraintDimensionRatio
which causes the problem together with layout_constraintHeight_max