views:

761

answers:

2

I want to display an image from an url with an Webview at Android.

With Android phones with Version 1.5 and 1.6 there is no problem. but the same pic and the same code on an AndroidPhone with Version 2.0 and the pic is totaly pixelated.

Like Android is resizing the image first to a smaller one and then resizing it back to "normal" size.

Unfortunately its important to display the pic without any quality loss.

I tried to integrate it in the sourcefolder to show it as an normal image, but at Android 2.0 i get an exception because the image is to big. (At Android 1.6 there is no problem)

Any ideas how i can display the image without quality loss with Android 2.0 ?

A: 

If you have not already done it, add this to your manifest :

 <supports-screens
      android:largeScreens="true"
      android:normalScreens="true"
      android:smallScreens="true"
      android:resizable="true"
      android:anyDensity="true" />

Without this, everything will be scaled.

Also, if you dont want your device/emulator to scale your drawables you have to create drawables for each density by putting a higher resolution version into hdpi folder

res/drawable-ldpi/my_icon.png       // icon image for low density
res/drawable-mdpi/dpi/my_icon.png   // icon for medium density
res/drawable-hdpi/my_icon.png       // icon image for high density
PHP_Jedi
thanks for your answer, but whenever i try to add "android:resizable=true" there is an error. It seems he doesnt know this parameter. Or do i have to add something other too ? I tried with minSdkVersion = 4.
Merlino
I dont think there should be anything more needed to make resizable=true work. I use minSdk 3 and targetSdk=5... but i dont think that should make any difference. Im using <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5" />
PHP_Jedi
What happens if you try to add an ImageView with an image, does the ImageView also get scaled. Do you see any artifacts on the image ? (just to test if your app is scaling the view or not)
PHP_Jedi
imageview works fine wehen the file is in the source and small enough. If not i get an out of memory exception. That was the reason i tried to display the image with an webview. i don get why i cant use resizable... whenever i try, i get "ERROR No resource identifier found for attribute 'resizable' in package 'android'"
Merlino
A: 

Use android:resizeable="true" instead of android:resizable="true". There is a missing "e".

Greets Klaus

Klaus
No? This says it's `resizable`: http://developer.android.com/guide/practices/screens_support.html
Daniel DiPaolo