溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Android ImageView ScaleTypes介紹

發(fā)布時(shí)間:2020-07-02 17:50:00 來源:網(wǎng)絡(luò) 閱讀:1016 作者:secondriver 欄目:移動(dòng)開發(fā)

  

       原文地址: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>

    


     圖片大于給定的空間截圖:


     Android ImageView ScaleTypes介紹



     圖片小于給定的空間截圖:

     Android ImageView ScaleTypes介紹

   

   PS:通過對(duì)比每種ScaleType的縮放效果圖,加深對(duì)ScaleType的理解。

向AI問一下細(xì)節(jié)

免責(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)容。

AI