I have a ListView with custom items defined in a relativeLayout, which includes an imageView with android:layout_width="match_parent"
and android:layout_height="wrap_content"
and a custom vector drawable as a source, which schematically looks like this:
+-------------------------------------------+
+ solid area | some picture +
+-------------------------------------------+
The issue is when I turn to the landscape mode the image gets scaled up (to mach the parent's width), however keeping the aspect ratio the height is increased, as well.
Ideally I would like to define a Content Inset (as I know it from iOS), so that the solid area above gets stretched to match the new width, and the 'some picture'-area is kept at the same aspect ratio. All in all I the scaling would happen such that the height of the image (and hence of the whole listView item) is kept the same.
You can get the solid area to stretch by using a
LinearLayout
with a layout weight in the child width. To make this work, you should assign a fixed width to theImageView
.Also, the
adjustViewBounds
attribute on theImageView
will help to maintain the correct aspect ratio.