您好,登錄后才能下訂單哦!
原文地址:http://bon-app-etit.blogspot.hk/2014/01/p_w_picpathview-scaletypes.html
當(dāng)圖片要在應(yīng)用程序上顯示的時(shí)候,我們需要關(guān)心它將以怎樣的方式進(jìn)行縮放,最基本的方式是在布局文件中的ImageView中設(shè)置正確的縮放類型(scaleType)。
Android中ImageView提供了以下不同的縮放類型:
center
centerInside
centerCrop
fitXY
fitStart
fitCenter(默認(rèn))
fitEnd
matrix(用于圖片的矩陣轉(zhuǎn)換)
下面提供設(shè)置不同的縮放類型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:通過對(duì)比每種ScaleType的縮放效果圖,加深對(duì)ScaleType的理解。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。