I noticed that when displaying images in my ImageView that are automatically scaled down to fit into the window, they are adding at least 50% added padding above and below the image even though the scaled ImageView image takes up less than 1/4 of the visible screen. When images that fit without resizing are shown, this doesn’t happen.
Why is this happening and what can I do to fix it?
If it matters, the top level layout is a LinearLayout containing a ScrollView that includes the following ImageView:
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
Why is this happening?
You have to tell Android that you want the
View‘s bounds to change after the scaling is done.This is done using
android:adjustViewBounds="true".