Here is my basic layout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:adjustViewBounds="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/welcome_hero" />
</LinearLayout>
I want the Image to scale while maintaining the aspect ratio to fit the screen, pushing any following views down.
This works just beautifully on my mdpi (LG LGP509) and hdpi (HTC G2, Nexus One) devices. However, on my Galaxy Nexus (xhdpi), the image stubbornly does not scale to fit. It leaves extra space on the sides.
Here is some more info:
the layout is in the generic layout/ folder
welcome_hero.png is in the drawables/ folder and has 320px width and 161px height
AndroidManifest.xml has this entry:
<uses-sdk
android:targetSdkVersion="10"
android:minSdkVersion="8" />
<supports-screens
android:xlargeScreens="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false" />
Some things I have tried:
- changing the scaleType to fitCenter, fitInside, or matrix yielded the same results as without
- changing ImageView height to fill_parent correctly scaled the image, but pushed all other views off screen
- threatening monitor with physical violence left me more frustrated
- explicitly set height and width to 320dp and 161dp changed nothing
- as mentioned above, I have tried new layouts both in IntelliJ's previewer and on physical devices
I have been going through StackOverflow for about 1.5 hours now looking at the hundreds of posts that seem similar to mine, but none seem to make things work on the Galaxy Nexus. I am trying desperately to be a good developer and make my stuff scale up to new phones, but this is proving to be difficult.