原文地址:http://bon-app-etit.blogspot.hk/2014/01/p_w_picpathview-scaletypes.html html
當圖片要在應用程序上顯示的時候,咱們須要關心它將以怎樣的方式進行縮放,最基本的方式是在佈局文件中的ImageView中設置正確的縮放類型(scaleType)。android
Android中ImageView提供瞭如下不一樣的縮放類型:app
centeride
centerInside佈局
centerCropspa
fitXY3d
fitStartxml
fitCenter(默認)htm
fitEndblog
matrix(用於圖片的矩陣轉換)
下面提供設置不一樣的縮放類型ImageView顯示的截圖
佈局文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/logo" android:scaleType="centerCrop" /> </RelativeLayout>
圖片大於給定的空間截圖:
圖片小於給定的空間截圖:
PS:經過對比每種ScaleType的縮放效果圖,加深對ScaleType的理解。