2011-08-31 931 views

回答

22

也許這是爲時已晚,但即使在今天,我遇到了同樣的問題,通過使用下面的代碼片段固定它。

所有對齊/縮放選項都在scaleType屬性中。

現在,如果你想用的ImageView的前頭對齊的圖像,使用android:scaleType="fitStart"

同樣,android:scaleType="fitEnd"將其與ImageView的底部對齊。

+2

可能你遲到了,但它幫助了我! :) – nithinreddy

+0

謝謝,這是解決方案 – ShadowGod

+1

'fitStart'把圖像放在左上角,'fitEnd'放在右下角。但是,如果你想在'底部中心'的圖像呢?爲此,Fresco提供了自定義scalType。 –

0

您可以包裝ImageViewFrameLayout和使用android:layout_gravity這樣排列:

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 
     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal|bottom" 
      android:src="@drawable/img_select_profile" /> 
</FrameLayout>