ImageView的縮放模式ScaleType

2021-08-07 01:41:33 字數 932 閱讀 9601

使用imageview.setscaletype(imageview.scaletype scaletype)方法或在xml布局檔案中使用android:scaletype可以設定縮放模式。

其中的引數為imageview.scaletype型別的列舉值,現將各值介紹如下:

imageview.scaletype.center

在檢視中使影象居中,不執行縮放。對應xml中語法:android:scaletype="center"。

imageview.scaletype.center_crop

imageview.scaletype.center_inside

均衡的縮放影象(保持影象原始比例),使的兩個座標(寬、高)都小於等於相應的檢視座標。影象則位於檢視的**。對應xml中語法:android:scaletype="centerinside"。

imageview.scaletype.fit_center

使用center方式縮放影象。對應xml中語法:android:scaletype="fitcenter"。

imageview.scaletype.fit_end

使用end方式縮放影象。對應xml中語法:android:scaletype="fitend"。

imageview.scaletype.fit_start

使用start方式縮放影象。對應xml中語法:android:scaletype="fitstart"。

imageview.scaletype.fit_xy

使用fill方式縮放影象。對應xml中語法:android:scaletype="fitxy"。

imageview.scaletype.matrix

繪製時,使用影象矩陣方式縮放。影象矩陣可以通過setimagematrix(matrix)設定。對應xml中語法:android:scaletype="matrix"。

ImageView的縮放模式

imageview.setscaletype 方法可以設定所顯示的縮放模式。其中引數如下 列舉值 imageview.scaletype center 位於檢視中間,但不執行縮放比例 imageview.scaletype center crop 按比例統一縮放 保持的尺寸比例 便於的兩維 寬度和高...

ImageView手勢 雙擊可縮放

import android.content.context import android.graphics.matrix import android.graphics.pointf import android.graphics.drawable.drawable import android....

imageview縮放問題,不能對齊螢幕的頂部

最近在寫介面的時候發現了乙個問題 就是我的不能緊靠在螢幕的上部,總是有乙個短空白,之後經過一番後解決了問題,特寫下來自己學習下 出現這種問題,需要對imageview中的做縮放 縮放的屬性如下 類概述 將邊界縮放,以適應檢視邊界時的可選項。常量 public static final imagevi...