2013-07-25 52 views
1

我試圖顯示全屏圖像,但似乎圖像失去了質量。我從URL中獲取圖像,我下載它並在顯示圖像時看起來很糟糕。我得到的圖像高分辨率,所以我不知道問題是什麼?全屏顯示圖像 - 失去質量android

這裏是我的佈局,在那裏我顯示圖像:

<?xml version="1.0" encoding="utf-8"?> 
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/full_screen_banner" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:contentDescription="@string/app_name" /> 

這裏是Java代碼:

imageViews.put(imageView, url); 
Bitmap bitmap = memoryCache.get(url); 
if (bitmap != null) 
    imageView.setImageBitmap(bitmap); 
+0

你在使用什麼類型的庫 –

回答

1

如果您使用的圖像加載器只是去imageloader類,然後

檢查這些行

private Bitmap decodeFile(File f) { 
    try { 
     // decode image size 
     BitmapFactory.Options o = new BitmapFactory.Options(); 
     o.inJustDecodeBounds = true; 
     BitmapFactory.decodeStream(new FileInputStream(f), null, o); 
     // Find the correct scale value. It should be the power of 2. 
     final int REQUIRED_SIZE = 100; 
     int width_tmp = o.outWidth, height_tmp = o.outHeight; 
     int scale = 1; 
     while (true) { 
      if (width_tmp/2 < REQUIRED_SIZE 
        || height_tmp/2 < REQUIRED_SIZE) 
       break; 
      width_tmp /= 2; 
      height_tmp /= 2; 
      scale *= 2; 
     } 
     // decode with inSampleSize 
     BitmapFactory.Options o2 = new BitmapFactory.Options(); 
     o2.inSampleSize = scale; 
     return BitmapFactory.decodeStream(new FileInputStream(f), null, o2); 
    } catch (FileNotFoundException e) { 
    } 
    return null; 
}