2012-01-29 105 views
5

我想與邊框來顯示圖像。下面的解決方案適用於某些圖像,但不適用於其他圖像。矛盾的圖像縮放爲Android:scaleType =「fitCenter」

到目前爲止,我最好的猜測是,它工作正常較小的圖像,而不是路數。

隨着較小的圖片,將溶液很好地顯示圖像用2像素的邊界。大圖片的背景太高。

我與我手動縮放圖像測試這個從2000說* 400到200 * 40。因此,它是相同的圖像,只有預分頻。

任何想法,爲什麼大量的圖片以同樣的方式爲規模較小的規模慣於?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:background="#ffffff" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" 
       android:gravity="center" > 

    <ImageView 
      android:id="@+id/testimage" 
      android:background="#000000" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/testimage2" 
      android:padding="2dip" 
      android:scaleType="fitCenter" 
      /> 
</LinearLayout> 
+0

你可能想嘗試scaleType的所有組合。 – 2012-01-29 10:41:53

+0

這就是我所做的,並以fitCenter結束。我確信它是正確的,但事實並非如此。 – tzrnee 2012-01-30 08:14:02

回答

5

刪除scaletype併爲您的Imageview使用android:adjustViewBounds =「true」。

+0

是的,這工作正常。謝謝! – tzrnee 2012-01-30 08:02:38