Right now, i am developing Android Application using SDK 1.5 and testing application on HTC Hero, its firmware is Android 1.5.
Let me come to actual point: in application, i am having an imageview for displaying image (Image resolution is 320*480), now imageview is displaying image in full-screen perfectly, but when i am trying to test it on HTC EVO 4G (having resolution 480*800), image gets stretch.
So, what i like to do is want to display 320*480 resolution image in all screen-resolution mobile ? i means to say,if the mobile is of higher resolution(i.e. 480*800 , 480*854, or else) than the image should be displayed in "Center" portion of the screen.
So displaying image in Center in all screen (without stretching or cutting) resolution other than 320*480, what attributes i have to set ?
Simply set the scaleType
attribute of your ImageView. Possible values here: ImageView.ScaleType
You might want to use CENTER
.
In addition you face another problem: You have to provide a hdpi image in addition to your mdpi image so your mdpi image does not get automatically scaled up to hdpi by the Android system, read more here: http://developer.android.com/guide/topics/resources/providing-resources.html
Edit: Oh, and I nearly forgot: The 'drawable-mdpi' and 'drawable-hdpi' folders are only possible if you build your project against at least Android 1.6. So you have to set your minSdkVersion
to 3 and your targetSdkVersion
to 4, and place your images into the normal 'drawable' folder in order for Android 1.5 to catch up. See this video from the Google I/O 2010 to learn more: Casting a wide net for all Android devices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With