2012-07-09 38 views
2

通過讀取的Android文檔,我期望與此佈局的畫面:CENTER_CROP不保持圖像比

<ImageView 
    android:id="@+id/avatar" 
    android:layout_width="fill_parent" 
    android:layout_height="150dip" 
    android:adjustViewBounds="true" 
    android:scaleType="centerCrop" /> 

填充佈局(150浸高度是唯一的條件)而沒有任何畸變:

CENTER_CROP縮放圖像均勻(維持圖像的寬高比 比),以使得圖像的兩個尺寸(寬度和高度)將是 等於或大於該視圖的相應尺寸更大的(減去 填充)。

這工作得很好,在手機上:

enter image description here

但在平板電腦上的圖像是完全扭曲:

enter image description here

怎麼可能說:「請你不水平拉伸「

回答

4

我認爲你將圖像指定爲背景而不是源。圖像看起來也延伸到手機上,並且CenterCrop應該可以正常工作。

嘗試使用setImageBitmap或「src」屬性,並讓我知道它是否工作。