I am attempting to accomplish what must surely be the simplest thing imaginable. I have a background image for a menu. I wish to display as much of that image as fits on the screen, at one pixel per pixel, with no scaling.
As far as I can tell, this is exactly what scaleType="center" is supposed to accomplish. Unfortunately, no matter what I do, it refuses to do what I want, and instead only shows a small portion of the image.
To clarify with real numbers, I have a 720x1280px background image in the sw320dp drawables folder, being called by my sw320dp layout. For any screensize between 320x480px and 720x1280px, they should call that layout and display a portion of that background image. So, a 480x800px Nexus One should display a 480x800px portion of the image. To try and do this, I have:
<ImageView
android:id="@+id/menuBackground"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
app:srcCompat="@drawable/menubackground_w720" />
Unfortunately, it doesn't work. Instead, it just displays a very small portion of the image, roughly equal to 320x480px plus or minus a little bit for aspect ratio.
After much swearing and tearing my hair out, I have narrowed the possibilities down to three plausible theories:
- I'm doing something really, really, unbelievably simple wrong in a stupid way.
- I fundamentally don't understand how dp works, as well as scalable layouts.
- The world is a bizarre, irrational Lovecraftian nightmare in which nothing makes any sense and I am doomed to forever chase my own tail in hopeless circles of madness.
Assuming that the third option, even if true, is a "won't fix", I'd appreciate if someone could tell me whether it's option one or two, and link me to an appropriate up-to-date resource. Thanks for any assistance!



Try using
I've been having same issue with imageviews and this solved my problem everytime.