views:

74

answers:

1

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 ?

+1  A: 

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 to learn more: http://code.google.com/intl/de/events/io/2010/sessions/casting-wide-net-android-devices.html

mreichelt
@mreichelt ya i have developed application in 1.5 and same application is also running well in 2.1 with the same screen, but in 2.1 enabled HTC 4G evo, image gets stretched, thats why i am asking
PM - Paresh Mayani
Have you even tried out my answers?
mreichelt
@mreichelt thanx for the answer..i have already seen this event IO/2010 video, let me try out your answer way....really i am facing "Different resolution" problem
PM - Paresh Mayani
@mreichelt let me know, how much resolution's image should i store in mdpi and in hdpi partciularly ??? pls let me know
PM - Paresh Mayani
Your question is answered in detail here: http://developer.android.com/guide/practices/screens_support.html
mreichelt
@mreichelt i have already seen that page, especially seen "Table 1. Examples of device screens supported by Android.", but from that table itself , i got confusion regarding the diffrent size image, so for hdpi/mdpi, which resolution's image should i store ? i am really stuck here
PM - Paresh Mayani
For hdpi images, they have to be 1.5 times as large as mdpi images.
mreichelt
For hdpi images, they have to be 1.5 times as large as mdpi images. So if you have an image of 320x480 for mdpi, the image must be of size 1.5*320 x 480*1.5 = 480 x 720 for hdpi devices. Of course the screen size might be different for other devices (many new devices have 480x800 or even 480x854), so maybe you may want to add other hdpi images by adding new drawable folders with the exact resolution.
mreichelt
@mreichelt thanx for such great information
PM - Paresh Mayani