2011-06-18 39 views
0

我從網站下載位圖,然後將其顯示在我的應用程序中。每當我下載該圖像並將其設置爲ImageView時,實際圖像上方或下方總是會有很多額外的空間。這個額外的空間是ImageView的一部分,並且只有在將ImageBitmap設置爲下載的位圖後纔會出現。 所以,這讓我覺得多餘的空間是位圖的一部分。 但是,當我在Webview中下載相同的圖像時,沒有額外的空間。Android之上和之下的額外空間位圖

如果您對爲什麼會發生這種情況有任何想法,請讓我知道!如果您需要更多信息,請告知我,謝謝。

編輯:這是我的代碼獲取位圖:

InputStream in = null; 
    Message msg = Message.obtain(); 
    msg.what = 1; 
    try{ 
     in = openHttpConnection(_url); 
     if (in != null) 
     { 
      Bitmap bit = BitmapFactory.decodeStream(in); 
      Bundle b = new Bundle(); 
      b.putParcelable("bitmap", bit); 
      msg.setData(b); 
      in.close(); 
     } 
    } catch (IOException e1) { 
     e1.printStackTrace(); 
    } 
    _handle.sendMessage(msg); 

而這就是我用那麼對於ImageView的,我從代碼中得到位圖上方:

imageV.setImageBitmap(comic); 

編輯2: 在嘗試使用來自不同網站的其他圖像之後,我發現這個空白區並不總是在那裏。鑑於此,代碼可能沒有任何問題,是否有任何關於刪除這些額外空間的建議,因爲它不會顯示在實際圖像中,也不顯示在webview中?

+0

我們需要看一些代碼。 – Haphazard

回答

0

imageSize = din.readInt();

imageName = din.readUTF();

byte b [] = new byte [imageSize]; din.readFully(b);

bmImg = BitmapFactory.decodeByteArray(b,0,b.length);

//這適用於我...... // din是DataInputStream對象。

相關問題